Advertisement
Guest User

Untitled

a guest
Jan 25th, 2021
751
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # Running the sample script on all AAD groups
  2.  
  3. # Connect and change schema
  4. Connect-MSGraph -ForceInteractive
  5. Update-MSGraphEnvironment -SchemaVersion beta
  6. Connect-MSGraph
  7.  
  8. $Groups = Get-AADGroup | Get-MSGraphAllPages
  9.  
  10. $AllAssignedApps = Get-IntuneMobileApp -Expand assignments | Select id, displayName, lastModifiedDateTime, assignments
  11. $AllDeviceCompliance = Get-IntuneDeviceCompliancePolicy -Select id, displayName, lastModifiedDateTime, assignments -Expand assignments
  12. $AllDeviceConfig = Get-IntuneDeviceConfigurationPolicy -Select id, displayName, lastModifiedDateTime, assignments -Expand assignments
  13.  
  14. # Device Configuration Powershell Scripts
  15. $Resource = "deviceManagement/deviceManagementScripts"
  16. $graphApiVersion = "Beta"
  17. $uri = "https://graph.microsoft.com/$graphApiVersion/$($Resource)?`$expand=groupAssignments"
  18. $DMS = Invoke-MSGraphRequest -HttpMethod GET -Url $uri
  19. $AllDeviceConfigScripts = $DMS.value
  20.  
  21. # Administrative templates
  22. $Resource = "deviceManagement/groupPolicyConfigurations"
  23. $graphApiVersion = "Beta"
  24. $uri = "https://graph.microsoft.com/$graphApiVersion/$($Resource)?`$expand=Assignments"
  25. $ADMT = Invoke-MSGraphRequest -HttpMethod GET -Url $uri
  26. $AllADMT = $ADMT.value
  27.  
  28.  
  29. Write-host "Total number of Apps found: $($AllAssignedApps.DisplayName.Count)" -ForegroundColor cyan
  30. Write-host "Total number of Device Compliance policies found: $($AllDeviceCompliance.DisplayName.Count)" -ForegroundColor cyan
  31. Write-host "Total number of Device Configurations found: $($AllDeviceConfig.DisplayName.Count)" -ForegroundColor cyan
  32. Write-host "Total number of Device Configurations Powershell Scripts found: $($AllDeviceConfigScripts.DisplayName.Count)" -ForegroundColor cyan
  33. Write-host "Total number of Device Administrative Templates found: $($AllADMT.DisplayName.Count)" -ForegroundColor cyan
  34. Write-host ""
  35.  
  36.  
  37.  
  38. #### Config
  39. Foreach ($Group in $Groups) {
  40. Write-host "AAD Group Name: $($Group.displayName)" -ForegroundColor Green
  41.  
  42.     # Apps
  43.     #$AllAssignedApps = Get-IntuneMobileApp -Filter "isAssigned eq true" -Select id, displayName, lastModifiedDateTime, assignments -Expand assignments | Where-Object {$_.assignments -match $Group.id}
  44.     #$AllAssignedApps = Get-IntuneMobileApp -Expand assignments | Select id, displayName, lastModifiedDateTime, assignments | Where-Object {$_.assignments -match $Group.id}
  45.  
  46.     $AssignedApps = $AllAssignedApps | Where-Object {$_.assignments.id -match $Group.id}
  47.     $DeviceCompliance = $AllDeviceCompliance | Where-Object {$_.assignments.id -match $Group.id}
  48.     $DeviceConfig = $AllDeviceConfig | Where-Object {$_.assignments.id -match $Group.id}
  49.     $DeviceConfigScripts = $AllDDeviceConfigScripts | Where-Object {$_.groupAssignments.id -match $Group.id}
  50.     $ADMT = $AllADMT | Where-Object {$_.assignments.id -match $Group.id}
  51.    
  52.     Write-host "Number of Apps found: $($AssignedApps.DisplayName.Count)" -ForegroundColor magenta
  53.    
  54.     #Write-host "Number of Apps found: $($AllAssignedApps.DisplayName.Count)" -ForegroundColor cyan
  55.     Foreach ($Config in $AssignedApps) {
  56.      
  57.         Write-host $Config.displayName -ForegroundColor Yellow
  58.      
  59.     }
  60.      
  61.    
  62.     # Device Compliance
  63.     Write-host "Number of Device Compliance policies found: $($DeviceCompliance.DisplayName.Count)" -ForegroundColor magenta   
  64.     #$AllDeviceCompliance = Get-IntuneDeviceCompliancePolicy -Select id, displayName, lastModifiedDateTime, assignments -Expand assignments | Where-Object {$_.assignments -match $Group.id}
  65.     #Write-host "Number of Device Compliance policies found: $($AllDeviceCompliance.DisplayName.Count)" -ForegroundColor cyan
  66.     Foreach ($Config in $DeviceCompliance) {
  67.      
  68.         Write-host $Config.displayName -ForegroundColor Yellow
  69.      
  70.     }
  71.      
  72.    
  73.     # Device Configuration
  74.     Write-host "Number of Device Configurations found: $($DeviceConfig.DisplayName.Count)" -ForegroundColor magenta
  75.     #$AllDeviceConfig = Get-IntuneDeviceConfigurationPolicy -Select id, displayName, lastModifiedDateTime, assignments -Expand assignments | Where-Object {$_.assignments -match $Group.id}
  76.     #Write-host "Number of Device Configurations found: $($AllDeviceConfig.DisplayName.Count)" -ForegroundColor cyan
  77.     Foreach ($Config in $DeviceConfig) {
  78.      
  79.         Write-host $Config.displayName -ForegroundColor Yellow
  80.      
  81.     }
  82.      
  83.     # Device Configuration Powershell Scripts
  84.     Write-host "Number of Device Configurations Powershell Scripts found: $($DeviceConfigScripts.DisplayName.Count)" -ForegroundColor magenta
  85.      
  86.     Foreach ($Config in $AllDeviceConfigScripts) {
  87.      
  88.         Write-host $Config.displayName -ForegroundColor Yellow
  89.      
  90.     }
  91.      
  92.    
  93.     # Administrative templates
  94.     Write-host "Number of Device Administrative Templates found: $($ADMT.DisplayName.Count)" -ForegroundColor magenta
  95.    
  96.     Foreach ($Config in $AllADMT) {
  97.      
  98.         Write-host $Config.displayName -ForegroundColor Yellow
  99.      
  100.     }
  101.    
  102.     Write-host ""
  103.  
  104. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement