Advertisement
Guest User

Untitled

a guest
Jan 25th, 2021
1,877
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # Run for specific group
  2.  
  3. # Connect and change schema
  4. Connect-MSGraph -ForceInteractive
  5. Update-MSGraphEnvironment -SchemaVersion beta
  6. Connect-MSGraph
  7.  
  8. # Which AAD group do we want to check against
  9. $groupName = "All-Windows"
  10.  
  11. #$Groups = Get-AADGroup | Get-MSGraphAllPages
  12. $Group = Get-AADGroup -Filter "displayname eq '$GroupName'"
  13.  
  14. #### Config Don't change
  15.  
  16. Write-host "AAD Group Name: $($Group.displayName)" -ForegroundColor Green
  17.  
  18. # Apps
  19. #$AllAssignedApps = Get-IntuneMobileApp -Filter "isAssigned eq true" -Select id, displayName, lastModifiedDateTime, assignments -Expand assignments | Where-Object {$_.assignments -match $Group.id}
  20. $AllAssignedApps = Get-IntuneMobileApp -Expand assignments | Select id, displayName, lastModifiedDateTime, assignments | Where-Object {$_.assignments -match $Group.id}
  21.  
  22. Write-host "Number of Apps found: $($AllAssignedApps.DisplayName.Count)" -ForegroundColor cyan
  23.  
  24. Foreach ($Config in $AllAssignedApps) {
  25.  
  26.     Write-host $Config.displayName -ForegroundColor Yellow
  27.  
  28. }
  29.  
  30.  
  31. # Device Compliance
  32. $AllDeviceCompliance = Get-IntuneDeviceCompliancePolicy -Select id, displayName, lastModifiedDateTime, assignments -Expand assignments | Where-Object {$_.assignments -match $Group.id}
  33. Write-host "Number of Device Compliance policies found: $($AllDeviceCompliance.DisplayName.Count)" -ForegroundColor cyan
  34.  
  35. Foreach ($Config in $AllDeviceCompliance) {
  36.  
  37.     Write-host $Config.displayName -ForegroundColor Yellow
  38.  
  39. }
  40.  
  41.  
  42. # Device Configuration
  43. $AllDeviceConfig = Get-IntuneDeviceConfigurationPolicy -Select id, displayName, lastModifiedDateTime, assignments -Expand assignments | Where-Object {$_.assignments -match $Group.id}
  44. Write-host "Number of Device Configurations found: $($AllDeviceConfig.DisplayName.Count)" -ForegroundColor cyan
  45.  
  46. Foreach ($Config in $AllDeviceConfig) {
  47.  
  48.     Write-host $Config.displayName -ForegroundColor Yellow
  49.  
  50. }
  51.  
  52. # Device Configuration Powershell Scripts
  53. $Resource = "deviceManagement/deviceManagementScripts"
  54. $graphApiVersion = "Beta"
  55. $uri = "https://graph.microsoft.com/$graphApiVersion/$($Resource)?`$expand=groupAssignments"
  56. $DMS = Invoke-MSGraphRequest -HttpMethod GET -Url $uri
  57. $AllDeviceConfigScripts = $DMS.value | Where-Object {$_.groupAssignments -match $Group.id}
  58. Write-host "Number of Device Configurations Powershell Scripts found: $($AllDeviceConfigScripts.DisplayName.Count)" -ForegroundColor cyan
  59.  
  60. Foreach ($Config in $AllDeviceConfigScripts) {
  61.  
  62.     Write-host $Config.displayName -ForegroundColor Yellow
  63.  
  64. }
  65.  
  66.  
  67.  
  68. # Administrative templates
  69. $Resource = "deviceManagement/groupPolicyConfigurations"
  70. $graphApiVersion = "Beta"
  71. $uri = "https://graph.microsoft.com/$graphApiVersion/$($Resource)?`$expand=Assignments"
  72. $ADMT = Invoke-MSGraphRequest -HttpMethod GET -Url $uri
  73. $AllADMT = $ADMT.value | Where-Object {$_.assignments -match $Group.id}
  74. Write-host "Number of Device Administrative Templates found: $($AllADMT.DisplayName.Count)" -ForegroundColor cyan
  75.  
  76. Foreach ($Config in $AllADMT) {
  77.  
  78.     Write-host $Config.displayName -ForegroundColor Yellow
  79.  
  80. }
  81.  
  82.  
  83.  
  84.  
  85.  
  86.  
  87.  
  88.  
  89.  
  90.  
  91.  
  92.  
  93.  
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106. # Running the sample script on all AAD groups
  107.  
  108. # Connect and change schema
  109. Connect-MSGraph -ForceInteractive
  110. Update-MSGraphEnvironment -SchemaVersion beta
  111. Connect-MSGraph
  112.  
  113. $Groups = Get-AADGroup | Get-MSGraphAllPages
  114. $Groups = $Groups | sort-object displayname
  115.  
  116. $AllAssignedApps = Get-IntuneMobileApp -Expand assignments | Select id, displayName, lastModifiedDateTime, assignments
  117. $AllDeviceCompliance = Get-IntuneDeviceCompliancePolicy -Select id, displayName, lastModifiedDateTime, assignments -Expand assignments
  118. $AllDeviceConfig = Get-IntuneDeviceConfigurationPolicy -Select id, displayName, lastModifiedDateTime, assignments -Expand assignments
  119.  
  120. # Device Configuration Powershell Scripts
  121. $Resource = "deviceManagement/deviceManagementScripts"
  122. $graphApiVersion = "Beta"
  123. $uri = "https://graph.microsoft.com/$graphApiVersion/$($Resource)?`$expand=groupAssignments"
  124. $DMS = Invoke-MSGraphRequest -HttpMethod GET -Url $uri
  125. $AllDeviceConfigScripts = $DMS.value
  126.  
  127. # Administrative templates
  128. $Resource = "deviceManagement/groupPolicyConfigurations"
  129. $graphApiVersion = "Beta"
  130. $uri = "https://graph.microsoft.com/$graphApiVersion/$($Resource)?`$expand=Assignments"
  131. $ADMT = Invoke-MSGraphRequest -HttpMethod GET -Url $uri
  132. $AllADMT = $ADMT.value
  133.  
  134.  
  135. Write-host "Total number of Apps found: $($AllAssignedApps.DisplayName.Count)" -ForegroundColor cyan
  136. Write-host "Total number of Device Compliance policies found: $($AllDeviceCompliance.DisplayName.Count)" -ForegroundColor cyan
  137. Write-host "Total number of Device Configurations found: $($AllDeviceConfig.DisplayName.Count)" -ForegroundColor cyan
  138. Write-host "Total number of Device Configurations Powershell Scripts found: $($AllDeviceConfigScripts.DisplayName.Count)" -ForegroundColor cyan
  139. Write-host "Total number of Device Administrative Templates found: $($AllADMT.DisplayName.Count)" -ForegroundColor cyan
  140. Write-host ""
  141. Write-host ""
  142. Write-host ""
  143.  
  144.  
  145.  
  146.  
  147. #### Config
  148. Foreach ($Group in $Groups) {
  149. Write-host "AAD Group Name: $($Group.displayName)" -ForegroundColor Green
  150.  
  151.     # Apps
  152.     #$AllAssignedApps = Get-IntuneMobileApp -Filter "isAssigned eq true" -Select id, displayName, lastModifiedDateTime, assignments -Expand assignments | Where-Object {$_.assignments -match $Group.id}
  153.     #$AllAssignedApps = Get-IntuneMobileApp -Expand assignments | Select id, displayName, lastModifiedDateTime, assignments | Where-Object {$_.assignments -match $Group.id}
  154.  
  155.     $AssignedApps = $AllAssignedApps | Where-Object {$_.assignments.id -match $Group.id}
  156.     $DeviceCompliance = $AllDeviceCompliance | Where-Object {$_.assignments.id -match $Group.id}
  157.     $DeviceConfig = $AllDeviceConfig | Where-Object {$_.assignments.id -match $Group.id}
  158.     $DeviceConfigScripts = $AllDeviceConfigScripts | Where-Object {$_.groupAssignments.id -match $Group.id}
  159.     $ADMT = $AllADMT | Where-Object {$_.assignments.id -match $Group.id}
  160.    
  161.     Write-host "Number of Apps found: $($AssignedApps.DisplayName.Count)" -ForegroundColor magenta
  162.    
  163.     #Write-host "Number of Apps found: $($AllAssignedApps.DisplayName.Count)" -ForegroundColor cyan
  164.     Foreach ($Config in $AssignedApps) {
  165.      
  166.         Write-host $Config.displayName -ForegroundColor Yellow
  167.      
  168.     }
  169.      
  170.    
  171.     # Device Compliance
  172.     Write-host "Number of Device Compliance policies found: $($DeviceCompliance.DisplayName.Count)" -ForegroundColor magenta   
  173.     #$AllDeviceCompliance = Get-IntuneDeviceCompliancePolicy -Select id, displayName, lastModifiedDateTime, assignments -Expand assignments | Where-Object {$_.assignments -match $Group.id}
  174.     #Write-host "Number of Device Compliance policies found: $($AllDeviceCompliance.DisplayName.Count)" -ForegroundColor cyan
  175.     Foreach ($Config in $DeviceCompliance) {
  176.      
  177.         Write-host $Config.displayName -ForegroundColor Yellow
  178.      
  179.     }
  180.      
  181.    
  182.     # Device Configuration
  183.     Write-host "Number of Device Configurations found: $($DeviceConfig.DisplayName.Count)" -ForegroundColor magenta
  184.     #$AllDeviceConfig = Get-IntuneDeviceConfigurationPolicy -Select id, displayName, lastModifiedDateTime, assignments -Expand assignments | Where-Object {$_.assignments -match $Group.id}
  185.     #Write-host "Number of Device Configurations found: $($AllDeviceConfig.DisplayName.Count)" -ForegroundColor cyan
  186.     Foreach ($Config in $DeviceConfig) {
  187.      
  188.         Write-host $Config.displayName -ForegroundColor Yellow
  189.      
  190.     }
  191.      
  192.     # Device Configuration Powershell Scripts
  193.     Write-host "Number of Device Configurations Powershell Scripts found: $($DeviceConfigScripts.DisplayName.Count)" -ForegroundColor magenta
  194.      
  195.     Foreach ($Config in $DeviceConfigScripts) {
  196.      
  197.         Write-host $Config.displayName -ForegroundColor Yellow
  198.      
  199.     }
  200.      
  201.    
  202.     # Administrative templates
  203.     Write-host "Number of Device Administrative Templates found: $($ADMT.DisplayName.Count)" -ForegroundColor magenta
  204.    
  205.     Foreach ($Config in $ADMT) {
  206.      
  207.         Write-host $Config.displayName -ForegroundColor Yellow
  208.      
  209.     }
  210.    
  211.     Write-host ""
  212.     Write-host ""
  213.     Write-host ""  
  214.  
  215. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement