User logon name change

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

  • Author
    Posts
  • #6177

    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 "domain.com/SomeOU" | ForEach-Object {
    $NewUsername = "$($_.FirstName)$(".")$($_.LastName)"

    $_ | Set-QADUser -SamAccountName $NewUsername -UserPrincipalName "$NewUsername@domain.com"

    }

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

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

You must be logged in to reply to this topic.