Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Write-Verbose "Display Name: $Display"
- $TruncatedBaseDisplay = (-join([char[]]$Display | select -first 15))
- $FirstUnusedName = (
- ($TruncatedBaseDisplay.Length)..1 | %{
- $ThisLength = $_;
- $Digits = 15 - $ThisLength;
- (-join([char[]]$Display | select -first $ThisLength)) | %{
- $ThisName = $_
- $Zeroes = -join('0'*$Digits)
- 0..([int64](-join('1',$Zeroes)) - 1) | %{-join($ThisName,$_)} | ?{-not(Get-ADUser -filter {samaccountname -eq $_})} | %{
- $_
- break
- }
- }
- }
- )
Add Comment
Please, Sign In to add comment