PowerShell uses the regional settings of Windows if the current date is queried via Get-Date
The settings can be checked with PowerShell via Get-Culture, and the detailed formats are shown in the Windows regional settings.
I would like to get a German name.
Get-Date -Format "dddd, dd.MM.yyyy" OR
Get-Date -Format "dddd, dd. MMMM yyyy"
The naming for weekday/month is not correct due to my English configuration
Instead of changing the regional settings, I can tell PowerShell which language it should use (once).
- For the weekday
$RegionalCulture = New-Object System.Globalization.CultureInfo("de-CH")
$DayName = $RegionalCulture.DateTimeFormat.GetDayName((Get-Date).DayOfWeek)
$Date = ("$DayName, " + (Get-Date -format "dd.MM.yyyy"))
$RegionalCulture.TextInfo.ToTitleCase($Date) # to capitalize the first character of the day
- For weekday and month
PowerShell also adapts the month’s name to the German name with a bit of addition.
$RegionalCulture = New-Object System.Globalization.CultureInfo("de-CH")
$DayName = $RegionalCulture.DateTimeFormat.GetDayName((Get-Date).DayOfWeek)
$MonthName = $RegionalCulture.DateTimeFormat.GetMonthName(((Get-Date).Month))
$Date = ("$DayName, " + (Get-Date -format "dd. MMMMM yyyy")).Replace((Get-Date -format MMMM),$MonthName)
$RegionalCulture.TextInfo.ToTitleCase($Date) # to capitalize the first character of day and month
The option can be changed to many languages by customizing the language once. Microsoft lists the regional language codes here. It also supports Romansh for Switzerland.
$RegionalCulture = New-Object System.Globalization.CultureInfo("rm-CH")
$DayName = $RegionalCulture.DateTimeFormat.GetDayName((Get-Date).DayOfWeek)
$MonthName = $RegionalCulture.DateTimeFormat.GetMonthName(((Get-Date).Month))
$Date = ("$DayName, " + (Get-Date -format "dd. MMMMM yyyy")).Replace((Get-Date -format MMMM),$MonthName)
$RegionalCulture.TextInfo.ToTitleCase($Date) # to capitalize the first character of day and month