Why Aren’t EmployeeType and Department Fields Updating with Get-MGuser?

0
1
Asked By CuriousCat1234 On

I'm a bit puzzled over a situation I'm facing while updating user profiles using PowerShell. I've been tasked with updating several hundred user records for HR, including fields like job titles and categorizing users as either permanent staff or contractors. I've managed to get most of this working, but I'm running into an issue where the EmployeeType and Department fields aren't reflecting the updates when I run Get-MGuser, even though they appear updated in EntraGUI.

Here's what I'm doing: After calling `Get-MGuser`, I populate the updates in a hashtable and then use the `Update-MGuser` command. I'm not receiving any errors in the process, which adds to my confusion. After running my script, I've noticed that the updated fields show correctly in EntraGUI, but the `Get-MGuser` results don't reflect this change.

I'd like to understand why this inconsistency exists and why the updates don't seem to show when I query them, even though they are saved correctly on the platform. Any insights?

2 Answers

Answered By PowerShellWiz On

You might want to adjust this part of your script: instead of trying to select properties immediately when fetching the user, just get the user with `Get-MGuser -userid $user.'Work email'`. Then, feed the whole user object directly into `Update-MGuser`. Also, double-check where `$DeptDIV` is coming from and ensure your other variables don’t have extra spaces. It could be affecting your updates too!

Answered By ScriptGuru88 On

It sounds like you're hitting a typical quirk with MS Graph. Basically, MS Graph is designed to be efficient, so it only returns properties that you specifically ask for. If you're not specifying the EmployeeType and Department in your `Get-MGuser` request, they'll come back blank. You might want to check your command and ensure you’re including those fields in your query properly!

InquisitiveDev91 -

Okay, I see what you're saying! But just to clarify, even if I specify '*' in my call, those fields still don’t show up? That’s what’s puzzling to me.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.