Author Posts

January 1, 2012 at 12:00 am

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 ' ',")