Rexxer

Some tips for me and other

Powershell + Replace user’s manager

$userobj = Get-ADObject -SearchBase “DC=local, DC=com” -Filter {objectClass -eq “user” -and objectCategory -eq “person” -and manager -eq “CN=manager,DC=local,DC=com”} -Properties name, manager, department
foreach ($user in $userobj) {
Set-ADObject -Identity $user -replace @{“manager”=”CN=manager2,DC=local,DC=com”}
write-host $user.name, $user.manager
}

Comments are currently closed.