Created
March 4, 2026 18:10
-
-
Save azurekid/ec6d473d64238cf0b12976c46d232502 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Find-AdmxUsage.ps1 | |
| param( | |
| [Parameter(Mandatory=$true)][string]$AdmxFileName | |
| ) | |
| Import-Module Microsoft.Graph.DeviceManagement -ErrorAction Stop | |
| Connect-MgGraph -Scopes "DeviceManagementConfiguration.Read.All","Directory.Read.All" | |
| $keywords = @($AdmxFileName.ToLower(), "mozilla", "firefox", "software\\policies\\mozilla", "mozilla.firefox") | |
| Write-Host "Checking uploaded ADMX files..." | |
| $uploaded = Get-MgDeviceManagement_GroupPolicyUploadedDefinitionFile -All | |
| $matches = $uploaded | Where-Object { $_.DisplayName -and ($_.DisplayName.ToLower() -like "*$AdmxFileName.ToLower()*" -or ($keywords | ForEach-Object { $_ -and ($_.ToLower() -in $_) })) } | |
| if (-not $matches) { | |
| Write-Host "No uploaded ADMX file found with that name." | |
| } else { | |
| foreach ($f in $matches) { | |
| Write-Host "Found: $($f.DisplayName) id:$($f.Id) status:$($f.Status)" | |
| $ops = Get-MgDeviceManagement_GroupPolicyUploadedDefinitionFile_GroupPolicyOperation -GroupPolicyUploadedDefinitionFileId $f.Id -ErrorAction SilentlyContinue | |
| if ($ops) { | |
| $ops | ForEach-Object { Write-Host " op: $($_.Id) type:$($_.OperationType) target:$($_.TargetId)" } | |
| } else { | |
| Write-Host " No groupPolicyOperations found." | |
| } | |
| } | |
| } | |
| Write-Host "`nScanning Group Policy configurations..." | |
| $gpcs = Get-MgDeviceManagement_GroupPolicyConfiguration -All | |
| foreach ($g in $gpcs) { | |
| $text = $g | ConvertTo-Json -Depth 5 | |
| if ($keywords | ForEach-Object { $text.ToLower().Contains($_) } | Where-Object { $_ }) { | |
| Write-Host "Match: $($g.DisplayName) id:$($g.Id)" | |
| $assigns = Get-MgDeviceManagement_GroupPolicyConfigurationAssignment -GroupPolicyConfigurationId $g.Id -ErrorAction SilentlyContinue | |
| Write-Host " assignments: $($assigns.Count)" | |
| } | |
| } | |
| Write-Host "`nScanning Settings Catalog configuration policies..." | |
| $cfgs = Get-MgDeviceManagement_ConfigurationPolicy -All | |
| foreach ($c in $cfgs) { | |
| $meta = $c | ConvertTo-Json -Depth 4 | |
| if ($keywords | ForEach-Object { $meta.ToLower().Contains($_) } | Where-Object { $_ }) { | |
| Write-Host "Policy metadata match: $($c.DisplayName) id:$($c.Id)" | |
| continue | |
| } | |
| $settings = Get-MgDeviceManagement_ConfigurationPolicySetting -ConfigurationPolicyId $c.Id -ErrorAction SilentlyContinue | |
| foreach ($s in $settings) { | |
| $sjson = $s | ConvertTo-Json -Depth 4 | |
| if ($keywords | ForEach-Object { $sjson.ToLower().Contains($_) } | Where-Object { $_ }) { | |
| Write-Host "Policy setting match: $($c.DisplayName) id:$($c.Id)" | |
| break | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment