Recently, I got a requirement to get the day of the week in PowerShell. In this tutorial, I will explain how to get the day of the week using PowerShell with examples.
To get the current day of the week in PowerShell, you can use the Get-Date cmdlet followed by accessing the DayOfWeek property. Simply run the command $dayOfWeek = (Get-Date).DayOfWeek and then output the result with Write-Output $dayOfWeek. This will return the current day of the week, such as “Monday” or “Tuesday”.
Get Day of Week in PowerShell
The best way to get the day of the week in PowerShell is by using the Get-Date cmdlet. This cmdlet returns the current date and time, and you can access various properties of the date object it returns, including the day of the week.
Example 1: Get the Current Day of the Week
To get the current day of the week, you can use the following command:
$dayOfWeek = (Get-Date).DayOfWeek
Write-Output $dayOfWeekThis command will output the current day of the week, such as “Monday,” “Tuesday,” etc.
I executed the above PowerShell script using VS code, and you can see the output in the screenshot below:

Get the Day of the Week as a Number
Sometimes, you might need the day of the week as a numerical value rather than a string. PowerShell makes this easy as well.
Example 2: Get the Day of the Week as a Number
You can cast the DayOfWeek property to an integer to get the day of the week as a number (0 for Sunday, 1 for Monday, etc.) in PowerShell:
$dayOfWeekNumber = [int](Get-Date).DayOfWeek
Write-Output $dayOfWeekNumberThis will output a number between 0 and 6, representing the day of the week.
Here is the output you can see in the screenshot below:

Check out Add Months to Date in PowerShell
Get the Day of the Week for a Specific Date
If you need to find out the day of the week for a specific date, you can use the Get-Date cmdlet with parameters to specify the date.
Example 3: Get the Day of the Week for a Specific Date
Here is an example of getting the day of the week for a specific date in PowerShell.
$specificDate = Get-Date -Year 2024 -Month 9 -Day 20
$dayOfWeek = $specificDate.DayOfWeek
Write-Output $dayOfWeekThis will output the day of the week for September 20, 2024.
You can see the exact output in the screenshot below:

Read PowerShell Date Comparison
Using Different Methods to Get the Day of the Week
PowerShell offers a variety of methods and properties to work with dates. Here are a few more examples.
Example 4: Using DayOfWeek Enumeration
You can also use the DayOfWeek enumeration to convert a string to its corresponding day of the week:
$day = [DayOfWeek]::Wednesday
Write-Output $dayThis will output “Wednesday.”
Example 5: Using ToString() Method
If you need a more customized output, you can use the ToString() method with format specifiers:
$dayOfWeek = (Get-Date).ToString("dddd")
Write-Output $dayOfWeekThis will output the full name of the day, such as “Monday.”
Conclusion
In this tutorial, I explained how to get the day of the week using PowerShell using different methods. I have also shown how to get the day of the week as a number and also how to get the Day of the Week for a Specific Date in PowerShell.
You may also like the following tutorials:
- How to Get Yesterday’s Date in PowerShell
- PowerShell Get-Date Format ISO 8601
- Get the Last Business Day of the Month Using PowerShell
Bijay Kumar is an esteemed author and the mind behind PowerShellFAQs.com, where he shares his extensive knowledge and expertise in PowerShell, with a particular focus on SharePoint projects. Recognized for his contributions to the tech community, Bijay has been honored with the prestigious Microsoft MVP award. With over 15 years of experience in the software industry, he has a rich professional background, having worked with industry giants such as HP and TCS. His insights and guidance have made him a respected figure in the world of software development and administration. Read more.