My all OU has some attribute in its property like APAC X0011, Europe X0012, America X0013 but in naming convention there is nothing which could bifurcate that which OU belongs to which region. So I have created script based on content attribute as mentioned above. SCRIPT IS PERFECT but when I run, it starts applying to all region. I want to apply it first for few OU like 10 OU so I can present it to my manager then later I will apply to all OUs. So in this script how can I filter only 10 OU in "-Search Base" . Any suggestion please.
get-adobject -filter 'name -eq "computers"' -searchbase "ou=Country,dc=Contoso,dc=com" -server Win2K16DC -Properties OfficeID,distinguishedname `| select OfficeID,distinguishedname `
| foreach {
$Office = $null
$Office = $_.OfficeID.substring(0,5)
$OUpath = $_.distinguishedname
switch ($Office)
{
"X0011" {New-GPLink -Name "Local-EUC-group-GPO1" -Target $OUpath}
"X0012" {New-GPLink -Name "Local-EUC-group-GPO2" -Target $OUpath}
"X0013" {New-GPLink -Name "Local-EUC-group-GPO3" -Target $OUpath}
}
}
Arif