Skip to content

Instantly share code, notes, and snippets.

@IISResetMe
Last active November 9, 2016 17:00
Show Gist options
  • Save IISResetMe/8917e9f47226044042f5 to your computer and use it in GitHub Desktop.
Save IISResetMe/8917e9f47226044042f5 to your computer and use it in GitHub Desktop.
Clean out orphaned Group Policy Templates from SYSVOL
gci "\\$(($d=$env:USERDNSDOMAIN))\sysvol\$d\Policies"|?{$_.Name-imatch"^(?<g>\{[A-F\d]{8}(-[A-F\d]{4}){3}-[A-F\d]{12}\})$"}|?{[ADSI]::Exists("LDAP://CN=$($Matches["g"]),CN=Policies,CN=System,DC=$($d-split"\."-join",DC=")")}|%{"{0} is an orphan, remove it"-f$_.FullName}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment