namerg
asked on
How to remove spaces of composed lastname ?
Hello,
I have to create AD users from a CSV and would like to know how to remove spaces of a composed last name, for example if an employee's full name is Neymar, Da Silva, then username will be dasilvan
Thanks for your help,
I have to create AD users from a CSV and would like to know how to remove spaces of a composed last name, for example if an employee's full name is Neymar, Da Silva, then username will be dasilvan
Thanks for your help,
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
does not matter
Yes it doesn't matter. If there is no space then you will get the same input string as a result..
ASKER
Will the following
$LastName = $_."Last Name" -replace "\s"
work ?
Yes..
$LastName = $_."Last Name" -replace " "
Will also work..
$LastName = $_."Last Name" -replace " "
Will also work..
what is $_ representing?
ASKER
Before:
$sam = $_."Last Name".ToLower() + $_."First Name".substring(0,1).ToLow er()
After:
$LastName = $_."Last Name" -replace "\s"
$sam = $LastName.ToLower() + $_."First Name".substring(0,1).ToLow er()
$sam = $_."Last Name".ToLower() + $_."First Name".substring(0,1).ToLow
After:
$LastName = $_."Last Name" -replace "\s"
$sam = $LastName.ToLower() + $_."First Name".substring(0,1).ToLow
That should do it..
ASKER
if lastname does not have space
$lastname=$lastname -replace "\s","" would not matter ?