User ID Change Script

Ask your PowerShell-related questions, including questions on cmdlet development!
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 15 years and 7 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
slogick
Posts: 1
Last visit: Mon Sep 15, 2008 6:08 am

User ID Change Script

Post by slogick »

I apologize in advance for my noobness, but I am trying to write 2 of my first scripts in powershell. I downloaded the Quest plugin for active directory and below is what I am trying to do with the scripts1st ScriptRead in an AD User ID, New User ID from a .csv file and rename the login ID from the old ID to the new ID. Something like thisInput FileOldUserID NewUserIdImport-CSV "C:users.csv | get-ADUser OldUserId | Set-ADUser NewUserIDLoop until EOFCan someone help me out with this?
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

User ID Change Script

Post by jvierra »

Best file CSV would be

OldUser, NewUser
"userid1","newuserid"

This will allow for odd characters in the id if they exist.

Assume input file like so:

[c:myfile.csv]
userid,newid
"user01","newuser01"
"user02,"newuser02"
[end of file]

import-csv users.csv |%{set-qaduser $_.userid -samaccountname $_.newid}


jvierra2008-09-15 14:48:38
This topic is 15 years and 7 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked