Guest User

Untitled

a guest
Jan 15th, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 KB | None | 0 0
  1. $Names = @{
  2. Willem = 'Van Oranje'
  3. Jan = 'van de Vecht'
  4. Piet = 'Paulusma'
  5. }
  6.  
  7. ForEach ($Row in $Names.GetEnumerator()) {
  8. $LastnameIndex = $Row.Value.LastIndexOf(' ')
  9.  
  10. If ($LastnameIndex -lt 1) {
  11. $LastName = $Row.Value
  12.  
  13. }
  14. $LastName = $Row.Value.Substring($LastnameIndex+1)
  15.  
  16. $Username = $Row.Name.Substring(0,1) + $LastName
  17. Write-Output $Username
  18. }
Add Comment
Please, Sign In to add comment