I often find myself in situations when I want to PSRemote multiple servers with server names in such a series that has same prefix server names and suffixed by a 2 digit number like-
sameprefix05 sameprefix06 sameprefix07 sameprefix08 sameprefix09 sameprefix10 sameprefix11 sameprefix12 sameprefix13 sameprefix14 sameprefix15
and to avoid saving the server names in a file and directly PSRemote them, I do something like in the below screenshot to generate the series
This is smart, but that doesn’t work because the single digit numbers don’t comply the server name nomenclature in the above example, which should be like 05 instead of 5
So I was wondering, there has to be a better way.
To our rescue PowerShell provides -f format operator which could be used to make this work.
This small trick helps me a lot in day-to-day operations and hopefully, will help you as well.
Please do follow me on twitter for more Interesting PowerShell material and don’t forget to Show-off cool trick to your colleagues, thanks for reading. Cheers! 😉
[twitter-follow screen_name=’singhprateik’ show_count=’yes’]