How to Get Day of Week in PowerShell (With Examples)


You can use the following methods to get the current day of the week in PowerShell:

Method 1: Get Day of Week as Number (e.g. 1=Monday, 7 = Sunday)

Get-Date -UFormat %u

Method 2: Get Day of Week as Full Name (e.g. “Sunday”)

Get-Date -UFormat %A

Method 3: Get Day of Week as Abbreviated Name (e.g. “Sun”)

Get-Date -UFormat %a

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

Example 1: Get Day of Week as Number in PowerShell

This article is currently being written on a Wednesday.

We can use the following syntax to get the current day of the week as a number between 1 and 7 in PowerShell:

Get-Date -UFormat %u

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

PowerShell get day of week as value

This returns 3, which is the number that corresponds to Wednesday as the day of the week.

Example 2: Get Day of Week as Full Name in PowerShell

We can use the following syntax to get the day of the week as a full name in PowerShell:

Get-Date -UFormat %A

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

PowerShell get day of week as full weekday name

This returns Wednesday, which is the day of the week represented as the full name.

Example 3: Get Day of Week as Abbreviated Name in PowerShell

We can use the following syntax to get the day of the week as an abbreviated name in PowerShell:

Get-Date -UFormat %a

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

PowerShell get day of week as abbreviated name

This returns Wed, which is the day of the week represented as the abbreviated name.

Note: You can find the complete documentation for the Get-Date cmdlet in PowerShell here.

Related Tutorials

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

PowerShell: How to Get Month Name
PowerShell: How to Get Yesterday’s Date
PowerShell: How to Sort an Array of Strings by Date

Leave a Reply