How to Get Month Name in PowerShell (With Examples)


You can use the following methods to get a particular month name in PowerShell:

Method 1: Get Full Month Name (e.g. “October”)

(Get-Culture).DateTimeFormat.GetMonthName(10)

Method 2: Get Abbreviated Month Name (e.g. “Oct”)

(Get-Culture).DateTimeFormat.GetAbbreviatedMonthName(10)

The following examples show how to use each method in practice.

Example 1: Get Full Month Name in PowerShell

We can use the following syntax to get the full month name for the 10th month of the year in PowerShell:

(Get-Culture).DateTimeFormat.GetMonthName(10)

The following screenshot shows how to use this syntax in practice:

PowerShell get full month name

This returns October, which is the full name of the month for the 10th month of the year.

If you want the full name of the current month, you can use the following syntax instead:

(Get-Culture).DateTimeFormat.GetMonthName((Get-Date).Month)

The following screenshot shows how to use this syntax in practice:

This article is currently being written on March 5, 2024, which is why this returns March.

Example 2: Get Abbreviated Month Name in PowerShell

We can use the following syntax to get the abbreviated month name for the 10th month of the year in PowerShell:

(Get-Culture).DateTimeFormat.GetAbbreviatedMonthName(10)

The following screenshot shows how to use this syntax in practice:

PowerShell get abbreviated month name

This returns Oct, which is the abbreviated name of the month for the 10th month of the year.

If you want the abbreviated name of the current month, you can use the following syntax instead:

(Get-Culture).DateTimeFormat.GetAbbreviatedMonthName((Get-Date).Month)

The following screenshot shows how to use this syntax in practice:

PowerShell get abbreviated month name of current month

This article is currently being written on March 5, 2024, which is why this returns Mar.

Feel free to use whichever method you prefer depending on whether or not you want to retrieve the full month name or an abbreviated name.

Related Tutorials

The following tutorials explain how to perform other common tasks in PowerShell:

How to Compare Dates in PowerShell
How to Get Date Without Time in PowerShell
How to Format a DateTime in PowerShell

Leave a Reply