PowerShell - Display months or days of the week in the desired culture
To support me, you can subscribe to the channel, share and like the videos, disable your ad blocker or make a donation. Thank you!
Hello,
If you want to display the months or days of the week as a string value in the desired culture to embed in logs or reports, here’s how to do it in Powershell.
# Display the names of the months in the culture used.1..12 | ForEach-Object -process {(Get-Culture).DateTimeFormat.GetMonthName($_)}
# Display the names of the abbreviated months in the crop used1..12 | ForEach-Object -process {(Get-Culture).DateTimeFormat.GetAbbreviatedMonthName($_)}
# Display the names of the days of the week in the culture used0..6 | ForEach-Object -process {(Get-Culture).DateTimeFormat.GetdayName($_)}# The week starts on Sunday
# Display the names of the abbreviated days of the week in the culture used0..6 | ForEach-Object -process {(Get-Culture).DateTimeFormat.GetAbbreviatedDayName($_)}
# Display the 1st letter of the days of the week in the culture used0..6 | ForEach-Object -process {(Get-Culture).DateTimeFormat.GetshortestdayName($_)}
# Display month names in another culture$Culture = 'en-us'1..12 | ForEach-Object -process {[cultureinfo]::GetCultureInfo($Culture).DateTimeFormat.GetMonthName($_)}
# Display the names of the abbreviated month in another culture1..12 | ForEach-Object -process {[cultureinfo]::GetCultureInfo($Culture).DateTimeFormat.GetAbbreviatedMonthName($_)}
# Display the names of the days of the week in another culture0..6 | ForEach-Object -process {[cultureinfo]::GetCultureInfo($Culture).DateTimeFormat.GetdayName($_)}
# Display the names of the abbreviated days of the week in another culture0..6 | ForEach-Object -process {[cultureinfo]::GetCultureInfo($Culture).DateTimeFormat.GetAbbreviatedDayName($_)}
# Display the 1st letter of the days of the week in another culture0..6 | ForEach-Object -process {[cultureinfo]::GetCultureInfo($Culture).DateTimeFormat.GetshortestdayName($_)}
# You can also change the culture directly in the Powershell environment[cultureinfo]::CurrentCulture = 'en-us
# Display the names of the months in the culture used1..12 | ForEach-Object -process {(Get-Culture).DateTimeFormat.GetMonthName($_)}
# Display the names of the abbreviated months in the crop used1..12 | ForEach-Object -process {(Get-Culture).DateTimeFormat.GetAbbreviatedMonthName($_)}
# List all available cultures# Windows Powershell[System.Globalization.CultureInfo]::GetCultures([System.Globalization.CultureTypes]::AllCultures)
# Powershell 7Get-Culture -ListAvailable
Related links
Powershell - Testing network connectivity and port accessibility
Testing network connectivity and port accessibility with PowershellPowershell - Display network connections (equivalent to netstat)
Display network connections (listening ports, active connections...)Powershell - Testing name resolution (equivalent to nslookup)
Powershell commands to test name resolution (equivalent to nslookup)Powershell - View and manage DNS configuration of network interfaces
Powershell commands to display and manage DNS configuration of network interfacesPowershell - Managing IP configuration of network interfaces
Powershell commands to view and modify the IP configuration of network interfacesPowershell - Managing the status and configuration of network interfaces
Powershell commands to view and modify the status and configuration of network interfaces (disable IPv6, enable/disable an interface)
Follow me on
Support me
Last content
Powershell - Testing network connectivity and port accessibility
Powershell - Display network connections (equivalent to netstat)
Powershell - Testing name resolution (equivalent to nslookup)
Powershell - View and manage DNS configuration of network interfaces
Powershell - Managing IP configuration of network interfaces
Powershell - Managing the status and configuration of network interfaces
Powershell and the Left Hand Side
Powershell - Managing disks, partitions and volumes