Last active
December 24, 2015 21:49
-
-
Save belotn/6867957 to your computer and use it in GitHub Desktop.
Desactivate GPO Parts without settings
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
Get-ADOrganizationalUnit -Filter 'OU -like "*Citrix*"' -SearchBase 'dc=fabrikam,dc=com' -Properties * |% { | |
$_.gpLink -split ']' } |? { | |
$_ -match '[0,2]$'} |% { | |
(($_ -replace '\[','').split(';')[0]) -replace 'LDAP://',''} |% { | |
get-adobject $_ -properties * } | | |
sort -Unique DisplayName |% { | |
if( $_.Flags -ne 3 ){ | |
if([bool]( gci "$($_.gPCFileSysPath)\User") -eq $false){ | |
if([bool](gci "$($_.gPCFileSysPath)\Machine") -eq $false){ | |
(get-gpo -Name $_.DisplayName).GpoStatus = "AllSettingsDisabled" | |
}else{ | |
(get-gpo -Name $_.DisplayName).GpoStatus = "UserSettingsDisabled" | |
} | |
}else { | |
if([bool](gci "$($_.gPCFileSysPath)\Machine") -eq $false){ | |
(get-gpo -Name $_.DisplayName).GpoStatus = "ComputerSettingsDisabled" | |
}ELSE{ | |
#do nothing | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment