Skip to content

Instantly share code, notes, and snippets.

@kevinblumenfeld
Created May 15, 2018 16:35
Show Gist options
  • Save kevinblumenfeld/0fa0437c6ead2839a9d4ac667e02c41b to your computer and use it in GitHub Desktop.
Save kevinblumenfeld/0fa0437c6ead2839a9d4ac667e02c41b to your computer and use it in GitHub Desktop.
$Name = -join([char[]]$display | select -first 15)
$i = 2
Write-Verbose "Display Name: $Display"
while (Get-ADUser -filter {samaccountname -eq $name}) {
$charsForIteration = ([string]$i).Length
$name = -join([char[]]$display | select -first (15 - $charsForIteration)) + $i
$i++
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment