Create a list of users:
Get-ADUser -filter * -SearchBase "OU=Disabled Users,OU=bein, DC=mydomain, DC=net" -properties Manager|?{$_.manager -notlike $NULL}|select Name,samaccountname,DistinguishedName|export-csv c:\temp\disUsers.csv
After verification, execute below to remove managers.
Import-csv c:\temp\disUsers.csv|foreach-object{set-aduser -id $_.samaccountname -manager $NULL -whatif}
No comments:
Post a Comment