-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathListIntunePolicy.ps1
46 lines (41 loc) · 1.53 KB
/
ListIntunePolicy.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# Prompt the user to sign in to Microsoft Graph
Connect-MSGraph
# Retrieve the device configuration profiles and app protection policies
$deviceProfiles = Get-IntuneDeviceConfiguration
$appProtectionPolicies = Get-IntuneAppProtectionPolicy
# Define an object to store the profile/policy details
$profilesAndPolicies = @()
# Add the device configuration profiles to the object
foreach ($profile in $deviceProfiles) {
$profileType = $profile.ODataType.Substring($profile.ODataType.LastIndexOf('.') + 1)
$platform = $profile.PlatformType
$profileDetails = [PSCustomObject] @{
Name = $profile.DisplayName
ID = $profile.Id
Type = $profileType
Platform = $platform
}
$profilesAndPolicies += $profileDetails
}
# Add the app protection policies to the object
foreach ($policy in $appProtectionPolicies) {
$policyType = $policy.ODataType.Substring($policy.ODataType.LastIndexOf('.') + 1)
$platform = $policy.Platform
$policyDetails = [PSCustomObject] @{
Name = $policy.DisplayName
ID = $policy.Id
Type = $policyType
Platform = $platform
}
$profilesAndPolicies += $policyDetails
}
# Group the profiles/policies by platform and type, and display the results
$profilesAndPolicies | Group-Object Platform,Type | Sort-Object Name | ForEach-Object {
$platform = $_.Name[0]
$type = $_.Name[1]
Write-Host "$platform $type profiles/policies:"
$_.Group | Sort-Object Name | ForEach-Object {
Write-Host "- $($_.Name) ($($_.ID))"
}
Write-Host ""
}