Mar 02 2021 09:37 AM
Hello I am trying to add a "1_" to the END of a list of Samaccountnames in AD. I found a script that will add it to the BEGINNING of the username but not the end. I have tried moving the 1_$ to then end of the last line but it does not work. Can anyone tell me how I can do this so the new Samaccountname is "aduser_1" instead of "1_aduser"? Below is the script I am using now. Thanks in advance!!
$storeusers = Get-Content -Path ".\users.txt"
ForEach ($storeuser in $storeusers) {
$ADuser = Get-ADUser $storeuser
Set-ADUser -Identity $aduser -SamAccountName "1_$($aduser.samaccountname)" -verbose
}
Mar 02 2021 11:41 AM
SolutionMar 02 2021 07:41 PM