Skip to content

Instantly share code, notes, and snippets.

@dpo007
Created February 3, 2020 16:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dpo007/e76fe4fe85837ce6d3af03bdc6acbcee to your computer and use it in GitHub Desktop.
Save dpo007/e76fe4fe85837ce6d3af03bdc6acbcee to your computer and use it in GitHub Desktop.
PowerShell function :: Retrieve list of Group Policy Objects that are not linked to any OU.
function Get-UnlinkedGPOs {
[string[]]$results = @()
Get-GPO -All | ForEach-Object {
if ( $_ | Get-GPOReport -ReportType XML | Select-String -NotMatch "<LinksTo>" ) {
$results += $_.DisplayName
}
}
return $results
}
# Usage:
# foreach ($gpo in Get-UnlinkedGPOs) {
# Write-Host $gpo
# }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment