Nov 29 2021 02:16 AM
We need to tag all the computers under ABC.com/_AB/Workstations/SGV/ADNWE.
"HAW" needs to be written to extensionattribute1 on computer objects.
Once the computer is moved out of this OU the tag must be removed.
Jan 11 2022 02:50 PM - edited Jan 22 2022 08:03 AM
To add, you could do a search for all computers in the ADNWE OU. Something like
$computers=get-adcomputer -filter * -properties * | where-object extensionattribute -ne 'HAW' | where-object distinguishedname -match 'ou=adnwe,ou=sgv,ou=workstations,ou=_ab,dc=abc,dc=com
foreach ($computer in $computers) {
set-adcomputer $computer -add @{ExtensionAttribute1="HAW}
}
To remove, you could do a search for all computers with a extensionattribute1 filled with HAW which is not present in the ADNWE OU. Something like
$computers=get-adcomputer -filter * -properties * | where-object extensionattribute -eq 'HAW' | where-object distinguishedname -notmatch 'ou=adnwe,ou=sgv,ou=workstations,ou=_ab,dc=abc,dc=com
foreach ($computer in $computers) {
set-adcomputer $computer -Clear "extensionAttribute1"
}
Does this work for you in your environment?
Jan 14 2022 07:40 AM
Jan 27 2022 02:53 AM
@vickynet Did one of our answers help you?