msgraph-sdk-powershell
msgraph-sdk-powershell copied to clipboard
Get-MgDevice returns $Null on defined value
Import-Module Microsoft.Graph.Identity.DirectoryManagement
# Auth to MSGraph
Connect-MgGraph -Scopes 'Device.Read.All, Directory.Read.All'
$mType = (Get-MgDevice -Search "displayName:$($hostname)" -ConsistencyLevel eventual -All -Debug).managementType
Write-Host "managementType >"$mType
Result:
managementType >
Debug Info:
DEBUG: [Authentication]: - AuthType: 'Delegated', AuthProviderType: 'InteractiveAuthenticationProvider', ContextScope: 'CurrentUser', AppName: 'Microsoft Graph PowerShell'. DEBUG: [Authentication]: - Scopes: [Device.Read.All, DeviceManagementConfiguration.ReadWrite.All, DeviceManagementManagedDevices.PrivilegedOperations.All, Directory.Read.All, Directory.ReadWrite.All, openid, profile, User.Read, User.Read.All, UserAuthenticationMethod.Read.All, email]. [SNIPPED] Body: { "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#devices", "value": [ { [SNIPPED]
"managementType": "MDM", [SNIPPED]}
Thanks for bringing this to our attention.
According to the API reference docs and service metadata (what is used to generate the module), ManagementType property is only available in beta. See API changelog at https://developer.microsoft.com/en-us/graph/changelog/?search=managementType. To use it as intended, you'll need to run the command under Select-MgProfile beta.
I'll follow up with the workload owner internally to understand why the API returns the property in v1.0 when it should only return be accessible through beta.
Thanks!
Closing as service issue. Workload owner will fix in v1.0.