You need all the days of the week or months, or even the whole alphabet in PowerShell? Here I will show you how to do that. Just take a look at the example below to learn how to find all those values mentioned in the headline of this article.
Code Sample
# Enumerate Weekdays
[Enum]::GetValues([System.DayOfWeek])
# Enumerate Months
(New-Object System.Globalization.DateTimeFormatInfo).MonthNames
# List Numbers
1..10
-10..-5
# List Alphabet
[char[]](65..90)
# Side note: List console colors
[Enum]::GetValues([System.ConsoleColor])
Nice one. Hope this is helpful.
Categories: PowerShell
1 reply »