Hello,
I am trying to get the first letter of the string and hold that in a variable for use later on in my code.
I have tried split which will split into an array for me which is fine however I require just the first letter
Does anyone know how I can do this? I have tried using regular expressions however they are not working and I am not too good with them wither.
Can anyone assist?
My code before the split is:
Get-QADUser -Title "teacher" , "Staff" , "Parent" |
ForEach-Object {
$UserName = $_.givenName + "." + $_.sn
$Count = $UserName.Length
if($Count -le "20") {
Set-QADUser -Identity $UserName `
-UserPrincipalName $UserName + "@" + $School + ".domain.com" `
-SamAccountName $UserName
else {
$FLetter = $UserName.Split("^")
$NewName = $FLetter + "." + $_.GivenName
Set-QADUser -Identity $NewName `
-UserPrincipalName $NewName + "@" + $School + ".domain.com" `
-SamAccountName $NewName
}
}
}
Many Thanks
James