You're welcome :)
I forgot to add the Identity parameter, so the code should look like:
get-content c:\Usertest.txt | Get-QADUser | foreach {
Set-QADUser -identity $_ -SamAccountName ($_.SamAccountName+'-old')
}
Once you know what name you want to give, renaming is not a problem. For instance, to remove the '-old' suffix you can do this:
Get-QADUser -sizeLimit 0 -ldap '(samAccountName=*-old)' | foreach {
Set-QADUser -identity $_ -SamAccountName ($_.SamAccountName.substring($_.SamAccountName.lastIndexOf("-"))
}
It retrieves all users that their SamAccountName attribute is ending with '-old', and then it is using the lastIndexOf() method to find all characetrs that occure before the "-" char.
HTH