Sunday, April 19, 2015

PowerShell foreach A to Z

I know that we can display the number sequentially on PowerShell by performing "1..10 | %{$_}".



Even reverse the number, PowerShell is supported.


How about alphabet?


It seems that PowerShell isn't support. However, we can do it by using ASCII table to convert the number to alphabet.

Perform "65..90 | %{[char]$_}" on PowerShell to display uppercase A to Z. 


To display lowercase a to z, we can perform "97..122 | %{[char]$_}".


It works perfectly.

Then, we can apply it to work with other cmdlets like New-Item, New-VM and so on.

Reference:

This posting is provided “AS IS” with no warranties, and confers no rights!

No comments:

Post a Comment