active directory - Compare two organizational units with Powershell -
i compare 2 organizational units users. can user list command:
ou_number_1: get-aduser -filter * -searchbase "ou=ou_number_1,ou=ou-sne_sharepoint,dc=vf,dc=local" | select samaccountname ou_number_2: get-aduser -filter * -searchbase "ou=ou_number_2,ou=ou-sne_sharepoint,dc=vf,dc=local" | select samaccountname
i homonymous these lists. have put users in lists , compare them ? or better idea ?
to summary, list homonymous of ou's.
/update
try
$usergroup1 = get-aduser -filter * -searchbase "ou=ou_number_1,ou=ou-sne_sharepoint,dc=vf,dc=local" | select samaccountname $usergroup2 = get-aduser -filter * -searchbase "ou=ou_number_2,ou=ou-sne_sharepoint,dc=vf,dc=local" | select samaccountname $userinbothou = compare-object $usergroup1 $usergroup2 -includeequal
be aware array $userinbothou
contains powershell objects. when want samaccountname, must that:
foreach($user in $userinbothou) { write-host $user.samaccountname }
because samaccountname attribute.
Comments
Post a Comment