The get-mguser command shows department but not the value

mitsu 81 Reputation points
2022-08-19T05:32:03.537+00:00

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,707 questions
0 comments No comments
{count} votes

Accepted answer
  1. Vasil Michev 95,836 Reputation points MVP
    2022-08-19T06:54:19.53+00:00

    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