I need to rename all domain accounts (samaccountname) and UPN with the data I will be provided with an excel (.csv) spreadsheet. SamAccount UPN prefix and name will be the same (firstname.lastname@example.org). I am a newbie powershell script and not familiar with PS syntax.
I created a .csv file titled “UserList.csv” within the same folder as my .ps1 script. Within the .csv file, I have 3 columns: UserID,sAMAccountName, UserPrincipalName.
The UserID column has the user logon names for the users. The sAMAccountName and UserPrincipalName columns have what the company would like the new user logons names to be.
I want to use Get-ADuser cmlet to export a list of all Domain users to CSV file and then try Set-ADuser after.
$UserList = Import-CSV C:\scripts\UserList.csv
ForEach ($User in UserList)
Get-ADUser -Filter “sAMAccountName -eq ‘$($User.UserID)’”
Am I on the right track?