Sometimes you need to lookup the ID of your Intune policies. Let’s say you have an issue with a specific policy and you have requested a service request to Microsoft for assistance. The Microsoft technician can ask you for the ID of the failing policy.
In this article I will describe how to get the ID’s of your Intune policies with Powershell and Graph API.
How to get the get-intunepolicy function.
Go to the Powershell Gallery (Thanks to Ondrej Sebela for creating this package)
Open Powershell as an admin and paste the code.
Install-Module -Name IntuneStuff Import-Module IntuneStuff -Force # connect to Graph API Connect-MSGraph # get all Intune policies Get-IntunePolicy -verbose
This will show you all Intune Policies which are in place at the moment with all details of these policies. It will look something like this:
As you can see this result is a not clear and gives you a lot of info.
By default, this function returns a single object with property names representing “policy sections” (such as app, AppConfigurationPolicy, CompliancePolicy, etc.) and their corresponding individual policies as values. If you prefer a different format, you can use the ‘flatOutput’ parameter to receive an array containing all the policies instead.
To get a better result that is more clear use this command:
Get-IntunePolicy -policyType ALL -basicoverview -flatoutput
As you can see the ID is now much more easier to lookup.
You can always use the command with the Export-csv to get a csv file in order to ease the lookup.
Get-IntunePolicy -policyType ALL -basicoverview -flatoutput | Export-Csv -Path C:\Temp\IntunePolicies.csv
This will create a CSV file named IntunePolicies.csv into your C:\Temp directory which you can import into Excel. And it will look like this:
What Kind of policies does this function returns?
These policies are returned by the function.
- Apps
- App Configuration policies
- App Protection policies
- Compliance policies
- Configuration policies
- Administrative Templates
- Settings Catalog
- Templates
- MacOS Custom Attribute Shell Scripts
- Device Enrollment Configurations
- Device Management PowerShell scripts
- Device Management Shell scripts
- Endpoint Security
- Account Protection policies
- Antivirus policies
- Attack Surface Reduction policies
- Defender policies
- Disk Encryption policies
- Endpoint Detection and Response policies
- Firewall policies
- Security baselines
- iOS App Provisioning profiles
- iOS Update Configurations
- Policy Sets
- Remediation Scripts
- S Mode Supplemental policies
- Windows Autopilot Deployment profiles
- Windows Feature Update profiles
- Windows Quality Update profiles
- Windows Update Rings
How to find the correct Graph API URL’s?
Open you Intune portal and click on e.g. the Compliance Policy, hit F12 to open the developer tools of your browser and refresh the page, filter on ‘graph’ and find the correct GET request.















0 Comments