microsoftgraph / msgraph-sdk-powershell

Powershell SDK for Microsoft Graph
https://www.powershellgallery.com/packages/Microsoft.Graph
Other
691 stars 165 forks source link

Get-MgDeviceManagementDeviceCompliancePolicyAssignment does not show the Target value #2399

Open nashein opened 10 months ago

nashein commented 10 months ago

Thanks for reporting the bug. Please ensure you've gone through the following checklist before opening an issue:

Describe the bug I cant see the Target of Assignment Compliance Policy in Intune using MS Graph

image

To Reproduce Steps to reproduce the behavior:

Import-Module Microsoft.Graph.DeviceManagement Get-MgDeviceManagementDeviceCompliancePolicyAssignment -DeviceCompliancePolicyId $deviceCompliancePolicyId

Expected behavior I should see the Target value like on Graph Explorer

image

Debug Output Get-MgDeviceManagementDeviceCompliancePolicyAssignment -DeviceCompliancePolicyId $CompliancePolicy.Id -Debug | FL DEBUG: [CmdletBeginProcessing]: - Get-MgDeviceManagementDeviceCompliancePolicyAssignment begin processing with parameterSet 'List'.

Confirm Continue with this operation? [Y] Yes [A] Yes to All [H] Halt Command [S] Suspend [?] Help (default is "Y"): A DEBUG: [Authentication]: - AuthType: 'Delegated', TokenCredentialType: 'InteractiveBrowser', ContextScope: 'CurrentUser', AppName: 'Microsoft Graph Command Line Tools'. DEBUG: [Authentication]: - Scopes: [Application.Read.All, AppRoleAssignment.ReadWrite.All, DeviceManagementApps.Read.All, DeviceManagementConfiguration.ReadWrite.All, DeviceManagementManagedDevices.Read.All, DeviceManagementManagedDevices.ReadWrite.All, Group.Read.All, openid, profile, User.Read, User.Read.All, email]. DEBUG: ============================ HTTP REQUEST ============================

HTTP Method: GET

Absolute Uri: https://graph.microsoft.com/v1.0/deviceManagement/deviceCompliancePolicies//assignments

Headers: FeatureFlag : 00000043 Cache-Control : no-store, no-cache User-Agent : Mozilla/5.0,(Windows NT 10.0; Microsoft Windows 10.0.19045; pl-PL),PowerShell/5.1.19041.3570 Accept-Encoding : gzip SdkVersion : graph-powershell/2.8.0 client-request-id : 72e49bd1-0ebb-4eef-a23c-2dc09d346fe0

Body:

DEBUG: ============================ HTTP RESPONSE ============================

Status Code: OK

Headers: Transfer-Encoding : chunked Vary : Accept-Encoding Strict-Transport-Security : max-age=31536000 request-id : client-request-id : x-ms-ags-diagnostic : {"ServerInfo":{"DataCenter":"Germany West Central","Slice":"E","Ring":"5","ScaleUnit":"001","RoleInstance":"FR2PEPF000001DC"}} OData-Version : 4.0 Date : Fri, 03 Nov 2023 14:30:27 GMT

Body: { "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#deviceManagement/deviceCompliancePolicies('cc26ee06-ae41-49c2-8d6d-8b2c081778a0')/assignment s", "value": [ { "id": "", "target": { "@odata.type": "#microsoft.graph.allDevicesAssignmentTarget" } } ] }

Id : Target : Microsoft.Graph.PowerShell.Models.MicrosoftGraphDeviceAndAppManagementAssignmentTarget AdditionalProperties : {}

DEBUG: [CmdletEndProcessing]: - Get-MgDeviceManagementDeviceCompliancePolicyAssignment end processing.

image

Module Version Get-Module Microsoft.Graph*

ModuleType Version Name ExportedCommands


Script 2.8.0 Microsoft.Graph.Authentication {Add-MgEnvironment, Connect-MgGraph, Disconnect-MgGraph, Get-MgContext...} Script 2.8.0 Microsoft.Graph.DeviceManagement {Get-MgAdminEdge, Get-MgAdminEdgeInternetExplorerMode, Get-MgAdminEdgeInternetExplorerModeSiteList, Get-MgAdminEdgeInternetExplorerModeSiteListCount...}

Environment Data $PSVersionTable

Name Value


PSVersion 5.1.19041.3570 PSEdition Desktop PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...} BuildVersion 10.0.19041.3570 CLRVersion 4.0.30319.42000 WSManStackVersion 3.0 PSRemotingProtocolVersion 2.3 SerializationVersion 1.1.0.1

Screenshots

Additional context

timayabi2020 commented 10 months ago

@nashein this is indeed a bug because I've also tried getting the raw output as a json object and within the object, the "target" object doesn't contain any record (key-value pairs). As we look for a solution for this, Kindly consider using the Invoke-MgGraphRequest as we work on fix for this issue. i.e. Invoke-MgGraphRequest -uri https://graph.microsoft.com/v1.0/deviceManagement/deviceCompliancePolicies/<Your Id>/assignments | ConvertTo-Json -Depth 4