Hello Experts, i need help to finish my script.
We have an Active Directory with 800 users, and we used to create an account based in the first letter of the name and the last name (e.g John lennon will be jlennon)
But now we need change it for the first dot last name so jlennon have to be replaced to john.lennon.
I started to do this with powershell but i'm facing some trouble to make it work.
Function List-ValidUsers{
$validUsers=Get-ADUser -Filter {enabled -eq $TRUE}
foreach ($user in $validUsers){
$new=($user.GivenName + ". " + $user.SurName).ToLower()
}
The problem is if a user have a name (e.g John Winston Ono Lennon, GivenName is John and Surname is Winston Ono Lennon)
So when i call my function it will create john.Winston Ono Lennon
How can i create a function to create only john.lennon?
Thank you very much.
Regards.
- Edited by Berveglieri Wednesday, September 09, 2015 12:23 AM