Well here we are at the last Friday of the year. In fact , the last Friday of the decade! On this auspicious occasion, let's have some PowerShell fun and celebrate Friday. No matter what you call it, I'm assuming Friday is your last typical workday and something we look forward to. However, the name Friday is obviously not universal. But PowerShell makes it easy to discover what to call it depending on where we are. In Windows, this is our culture.
ManageEngine ADManager Plus - Download Free Trial
Exclusive offer on ADManager Plus for US and UK regions. Claim now!
This is a .NET object that has some interesting properties.
As you can see it is pretty easy to find out what "Friday" is called.
In Windows PowerShell, to check another culture you have to resort to using the .NET Framework.
I'm not even going to try and pronounce this but this is "Friday" in Finland. What about the rest of the world?
First, let's get all available cultures.
$all = [System.Globalization.CultureInfo]::GetCultures("allCultures")
Next, let's see what "Friday" is around the world.
$all | Select-object -property Name,DisplayName,@{Name="Friday";Expression = {$_.Datetimeformat.daynames[-2]}}
Or here's a random sample.
By the way, if you were curious about the rest of the week you could use code like this:
[System.Globalization.CultureInfo]::GetCultures("allCultures") | Format-Table -group DisplayName -Property Name, @{Name="Day1";Expression = {$_.Datetimeformat.daynames[0]}}, @{Name="Day2";Expression = {$_.Datetimeformat.daynames[1]}}, @{Name="Day3";Expression = {$_.Datetimeformat.daynames[2]}}, @{Name="Day4";Expression = {$_.Datetimeformat.daynames[3]}}, @{Name="Day5";Expression = {$_.Datetimeformat.daynames[4]}}, @{Name="Day6";Expression = {$_.Datetimeformat.daynames[5]}}, @{Name="Day7";Expression = {$_.Datetimeformat.daynames[6]}} -AutoSize
I 'll let you try it for yourself.
If you are running PowerShell 7, this is even easier as the Get-Culture cmdlet has been updated.
Not only can we now specify a culture, we can easily list all of them.
#requires -version 7.0 Get-Culture -ListAvailable | Select-Object Name,Displayname, @{Name="Friday";Expression = {$_.Datetimeformat.daynames[-2]}}
No matter what day it is I hope you enjoy it. And for some of you, "Friday" has already come and gone. Hope it was a good one.
It’s hard to believe that it’s been a decade since Ed Wilson switched from vbscript to PowerShell and James Brundage introduced WPK as a kit to build your own tools. This certainly was a decade of PowerShell enjoyable scripting, so Cheers to all those that brought PS to the public!