The get-mguser command shows department but not the value

mitsu 66 Reputation points

The get-mguser command shows department but not the value. displayed on the management screen.

Microsoft Graph Groups API
Microsoft Graph Groups API
A Microsoft API that creates and manages different types of groups and group functionality.
190 questions
No comments
{count} votes

Accepted answer
  1. Vasil Michev 66,956 Reputation points MVP

    By default, the Graph API (and the corresponding MG* PowerShell cmdlets) only return certain properties. You have two options here. First, explicitly request the Department property:

    Get-MgUser -UserId 821d8474-bc34-4671-9a4f-7573601e6285 -Property Department | select Department  

    (do note that if you want other properties in the output, you also have to specify them, i.e. -Property Id,DisplayName,Department)

    The second (and probably easier) method is to switch to using the /beta endpoint, which returns all properties by default:

    Select-MgProfile beta  
    Get-MgUser -UserId 821d8474-bc34-4671-9a4f-7573601e6285 | select Department  

0 additional answers

Sort by: Most helpful