Jump to content

Need to import EmployeeID values into AD via PowerShell


Recommended Posts

Posted

Here is what I have so far:

 

Sample of CSV

 

User,ID
jsmith,1234
jdoe,5678

 

PowerShell Script

 

Import-CSV "C:\Scripts\Users.csv" | % { 
$User = $_.UserName 
$ID = $_.EmployeeID 
Set-ADUser $User -EmployeeID $ID 
} 

 

Here is the error that I am running into

 

Set-ADUser : Cannot validate argument on parameter 'Identity'. The argument is null. Provide a valid value for theargument, and then try running the command again.
At line:4 char:12
+ Set-ADUser $User -EmployeeID $ID
+            ~~~~~
   + CategoryInfo          : InvalidData: ( [set-ADUser], ParameterBindingValidationException
   + FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.ActiveDirectory.Management.Commands.SetADUser

 

Any ideas? Thanks!

Posted

Thanks! Just ran across the forums today when I was researching this issue. I can see myself frequenting the site!

 

I actually used the script that you linked. I just didn't include the Import-Module ActiveDirectory statement in the post. I'm no PowerShell expert by any means (mostly do SQL stuff for my district) but this one is stumping me.

Posted (edited)
Here is what I have so far:

 

Sample of CSV

 

[color="#FF0000"][b]User,ID[/b][/color]
jsmith,1234
jdoe,5678

 

PowerShell Script

 

Import-CSV "C:\Scripts\Users.csv" | % { 
$User =[color="#FF0000"] [b]$_.UserName [/b][/color]
$ID =[color="#FF0000"][b] $_.EmployeeID [/b][/color]
Set-ADUser $User -EmployeeID $ID 
} 

 

!

 

Based on that original part you made surely you're importing the wrong part?

 

On that script your CSV should have Username and EmployeeID in your CSV, not User/ID.

 

Steve

Edited by Steve21
  • Thanks 1
Posted

Doh! Changing the CSV column headers was it. I was mixed up about where the variables had to be placed in the script.

 

Thanks!

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...