User logon name change

Welcome Forums General PowerShell Q&A User logon name change

This topic contains 0 replies, has 1 voice, and was last updated by  Forums Archives 7 years ago.

  • Author
  • #6177

    Points: 0
    Rank: Member

    by diprima at 2012-09-12 11:26:50

    Hello, I need help with the following. I need to change all of our user logon names in AD to firstName.LastName
    The only catch is there is a space in all the users first names. I have the below script which works great except I do not how to remove the space in the users first name.. Please help if I need two scripts that would work as well .. Thanks

    example first name = OPS John
    last name= Doe

    How would you modify the script below to remove the space so the user logon name would be
    opsjohn.doe instead of ops john.doe

    Get-QADUser -SearchRoot "" | ForEach-Object {
    $NewUsername = "$($_.FirstName)$(".")$($_.LastName)"

    $_ | Set-QADUser -SamAccountName $NewUsername -UserPrincipalName "$"


    by DonJ at 2012-09-12 14:04:50

    $($_.FirstName -replace ' ',")

The topic ‘User logon name change’ is closed to new replies.