Jump to content
EduGeek EdSec 2026 is Go! 27th Oct in Derby! Join us for a day of EdTech security focused talks, networking, and an evening social ×

Recommended Posts

Posted

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

Posted

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

}

  • Thanks 1
Posted

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

}

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 account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...