Pad Session host name with Leading Zeros

Pad Session host name with Leading Zeros
2

Upvotes

Upvote

 Jun 29 2021
1 Comments (1 New)
New

When adding session hosts to a pool you declare a prefix and the template will append an incrementing number to the end. but this number is not a consistent length due to the lack of leading zeros. and in large host pool, this causes the hosts to not sort properly 

CurrentExample of Bad SortDesired
Test-VM-1Test-VM-1Test-VM-001
Test-VM-2Test-VM-10Test-VM-002
Test-VM-3Test-VM-11Test-VM-003
Test-VM-4Test-VM-12Test-VM-004
Test-VM-5Test-VM-2Test-VM-005
Test-VM-6Test-VM-3Test-VM-006
Test-VM-7Test-VM-4Test-VM-007
Test-VM-8Test-VM-5Test-VM-008
Test-VM-9Test-VM-6Test-VM-009
Test-VM-10Test-VM-7Test-VM-010
Test-VM-11Test-VM-8Test-VM-011
Test-VM-12Test-VM-9Test-VM-012
Comments
Occasional Contributor

I agree, this is annoying. I have to use this really useful Sort-STNumerical PowerShell function to get the desired effect.
Sort strings with numbers more humanely in PowerShell - Svendsen Tech PowerShell Wiki (powershelladm...

Similar Ideas
No similar ideas