Created
February 3, 2020 16:05
-
-
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.
This file contains 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
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