RoyHobbs Posted June 13, 2016 Posted June 13, 2016 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!
linkazoid Posted June 13, 2016 Posted June 13, 2016 (edited) Import-module ActiveDirectory Import-CSV "C:\Scripts\Users.csv" | % { $User = $_.UserName $ID = $_.EmployeeID Set-ADUser $User -employeeID $ID } https://gallery.technet.microsoft.com/scriptcenter/e9bafc1a-b5b1-4663-8e25-b0d0ea28c2b2 Oh and Welcome to the forums! Edited June 13, 2016 by linkazoid
RoyHobbs Posted June 13, 2016 Author Posted June 13, 2016 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.
Steve21 Posted June 14, 2016 Posted June 14, 2016 (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 June 14, 2016 by Steve21 1
RoyHobbs Posted June 14, 2016 Author Posted June 14, 2016 Doh! Changing the CSV column headers was it. I was mixed up about where the variables had to be placed in the script. Thanks!
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