The get-mguser command shows department but not the value

mitsu 81 Reputation points

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

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,447 questions
0 comments No comments
{count} votes

Accepted answer
  1. Vasil Michev 94,131 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