0

I have limited exposure to Powershell so I need some help.

I have a CSV file with just the SamAccounName. I would like to use powershell to import that file and update the employeeID attribute with the sammaccountname value. The import is the easy part:

$users = Import-Csv c:\filename.csv

Using the file to update the employeeid attribute is what I need help with. Thanks in advance for your help.

1
  • Please edit your question so as to include a Minimal, Complete, and Verifiable example. Also, you have mentioned SamAccounName and sammaccountname. Are these actually different, or Is that a typo? Commented Oct 6, 2016 at 19:50

1 Answer 1

1

There is some great documentation about this here so you can get a good idea about this: https://technet.microsoft.com/en-us/library/ee617215.aspx

With RSAT Running you need to Import the AD Cmdlet's Import-Module ActiveDirectory

Once this is done you are starting to head down the appropriate path, try working with the following:

Import-CSV $csvFile | forEach { Set-ADUser $_.SamAccountName -EmployeeID $_.SamAccountName -WhatIf }

This can go much further, have a look at the top link instead of copying and pasting this code as you don't want to make error on this. But there should be enough information here to get you up and running.

Note the '-WhatIf' in the above code means PoSh will tell you what will happen rather than making it happen.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks much. Exactly what I needed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.