Tuesday, June 4, 2013

PowerShell script to apply a specific GPO and disable another Specific GPO .

$ohewes = Get-ADOrganizationalUnit -LDAPFilter '(name=*)' -searchbase 'ou=users,ou=users,ou=users,dc=ie,dc=companyname,dc=companyname,dc=com' -searchscope Onelevel | Where-object {$_.name -notlike "IT" -and $_.name -notlike "Unassigned*"}

$ohewes | ForEach-Object {
    New-GPLink -name "EncryptionCheck - UserPolicy" -target $_.DistinguishedName  -linkEnabled Yes
}

$ohewes | ForEach-Object { set-GPLink -name "OldEncryptionCheck - User Policy" -target $_.DistinguishedName  -linkEnabled no -whatif }

No comments:

Post a Comment