-
Notifications
You must be signed in to change notification settings - Fork 237
/
intune-policy-get.ps1
70 lines (57 loc) · 2.15 KB
/
intune-policy-get.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<#CIAOPS
Script provided as is. Use at own risk. No guarantees or warranty provided.
Description - Return the name of all policies configured in EndPoint Manager (Intune and Endpoint)
Source - https://github.com/directorcia/office365/blob/master/intune-policy-get.ps1
Prerequisites = 1
1. Ensure connected to Intune - Use https://github.com/directorcia/Office365/blob/master/Intune-connect.ps1
#>
## Variables
$systemmessagecolor = "cyan"
$processmessagecolor = "green"
$errormessagecolor = "red"
$warningmessagecolor = "yellow"
Clear-Host
write-host -foregroundcolor $systemmessagecolor "Script started"
Try {
Import-Module Microsoft.Graph.Intune | Out-Null
}
catch {
Write-Host -ForegroundColor $errormessagecolor "`n[001] - Failed to import Intune module - ", $_.Exception.Message
exit 1
}
try {
Connect-MSGraph | Out-Null
}
catch {
Write-Host -ForegroundColor $errormessagecolor "`n[002] - Failed to connect to Intune - ", $_.Exception.Message
exit 2
}
<# Intune policies #>
write-host -foregroundcolor $processmessagecolor "`nIntune Compliance policies"
$pols = Get-IntuneDeviceCompliancePolicy
Foreach ($pol in $pols){
write-host " - "$pol.displayname
}
write-host -foregroundcolor $processmessagecolor "`nIntune Configuration policies"
$pols = Get-IntuneDeviceConfigurationPolicy
Foreach ($pol in $pols){
write-host " - "$pol.displayname
}
write-host -foregroundcolor $processmessagecolor "`nIntune App protection policies"
$pols = Get-IntuneappprotectionPolicy
Foreach ($pol in $pols){
write-host " - "$pol.displayname
}
write-host -foregroundcolor $processmessagecolor "`nIntune App configuration policies (targeted)"
$pols = Get-IntuneappconfigurationPolicytargeted
Foreach ($pol in $pols){
write-host " - "$pol.displayname
}
<# EndPoint Policies #>
$uri = "https://graph.microsoft.com/beta/deviceManagement/intents"
$Configs = (Invoke-MSGraphRequest -Url $uri -HttpMethod GET).Value
write-host -foregroundcolor $processmessagecolor "`nEndPoint policies"
foreach ($config in $configs) {
write-host " - "$config.displayname
}
Write-Host -ForegroundColor $systemmessagecolor "`nScript Finished"