Forum Discussion
JeremyTBradshaw
Jan 21, 2021Steel Contributor
Get-IntuneDeviceConfigurationPolicy returns only some of my policies
FYI: I also opened an issue on the GitHub repo for the module When I run Get-IntuneDeviceConfigurationPolicy, I'm getting 5 device configuration policies back, but I actually have 10: >Get-Intu...
- Jun 30, 2021
What happens when you run this script? It shows me the stuff the other command didn't showed me
#oauth token
$clientId = "d1ddf0e4-d672-4dae-b554-9d5bdfd93547"
$redirectUri = "urn:ietf:wg:oauth:2.0:oob"
$resourceURI = "https://graph.microsoft.com/"
$authority = "https://login.microsoftonline.com/common"
$AadModule = Import-Module -Name AzureAD -ErrorAction Stop -PassThru
$adal = Join-Path $AadModule.ModuleBase "Microsoft.IdentityModel.Clients.ActiveDirectory.dll"
$adalforms = Join-Path $AadModule.ModuleBase "Microsoft.IdentityModel.Clients.ActiveDirectory.Platform.dll"
[System.Reflection.Assembly]::LoadFrom($adal) | Out-Null
[System.Reflection.Assembly]::LoadFrom($adalforms) | Out-Null
$authContext = New-Object "Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContext" -ArgumentList $authority
$platformParameters = New-Object "Microsoft.IdentityModel.Clients.ActiveDirectory.PlatformParameters" -ArgumentList "Always"
$authResult = $authContext.AcquireTokenAsync($resourceURI, $ClientID, $RedirectUri, $platformParameters)
$accessToken = $authResult.result.AccessToken
$apiUrl = 'https://graph.microsoft.com/beta/deviceManagement/deviceconfigurations'
$Data = Invoke-RestMethod -Headers @{Authorization = "Bearer $($authResult.result.AccessToken)"} -Uri $apiUrl -Method get
$data.valueTHe script I posted is connecting to the beta and shows it all, but the msgraph is connecting to the v1.0
So if you want the get-intunedeviceconfiguraitonpolicy to connect to the beta:
Update-MSGraphEnvironment -SchemaVersion beta
connect-msgraph
dkovarik
Sep 04, 2024Copper Contributor
Actually, what helped me after all tries to get ALL configuration policies is this:
1) use Beta version of Graph API
2) get data from all these API points:
- deviceManagement/deviceConfigurations
- deviceManagement/configurationPolicies
- deviceManagement/grouppolicyconfigurations
With the 3 API points above, you will get the list with record IDs, on which you can use further API calls like:
- deviceManagement/deviceConfigurations/{RECORD ID}/deviceStatusOverview
- deviceManagement/deviceConfigurations/{RECORD ID}/deviceStatuses
1) use Beta version of Graph API
2) get data from all these API points:
- deviceManagement/deviceConfigurations
- deviceManagement/configurationPolicies
- deviceManagement/grouppolicyconfigurations
With the 3 API points above, you will get the list with record IDs, on which you can use further API calls like:
- deviceManagement/deviceConfigurations/{RECORD ID}/deviceStatusOverview
- deviceManagement/deviceConfigurations/{RECORD ID}/deviceStatuses
MrMattiPants
Sep 22, 2024Copper Contributor
dkovarik
If you have any Hardware Configurations, you may also want to include the "hardwareConfigurations" Resource Type, as well.