Bezwick Posted March 12, 2013 Posted March 12, 2013 Hi everyone, was wondering if one of you could help me with this script. I have been asked to import our student SIMS id into the EmloyeeID attribute in Active Directory and have come across this little script. Import-module ActiveDirectory Import-CSV "C:\users.csv" | % { $User = $_.UserName $ID = $_.EmployeeID Set-ADUser $User -employeeID $ID } However it appears to only scan the default user OU at the root of the domain. Anyone know how to modify it so it scans all OU's in the active directory or at least what commands i need to add so that it can search a specific OU? Thanks
ascott2 Posted March 12, 2013 Posted March 12, 2013 Strange as using a unique identifier like SAMAccountName, it shouldn't matter where it is, Set-ADUSer should find it. Out of interest if you modify your script to Get-ADUser rather than Set do you see the same results? If using get works you could modify your script to Import-module ActiveDirectory Import-CSV "C:\users.csv" | % { $User = $_.UserName $ID = $_.EmployeeID Get-ADUser $User | Set-ADUser -employeeID $ID } 1
Bezwick Posted March 13, 2013 Author Posted March 13, 2013 That worked Thanks Strange as using a unique identifier like SAMAccountName, it shouldn't matter where it is, Set-ADUSer should find it. Out of interest if you modify your script to Get-ADUser rather than Set do you see the same results? If using get works you could modify your script to Import-module ActiveDirectory Import-CSV "C:\users.csv" | % { $User = $_.UserName $ID = $_.EmployeeID Get-ADUser $User | Set-ADUser -employeeID $ID }
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now