Converting VBScript's WeekdayName Function
Definition: Returns a string indicating the specified day of the week.
WeekdayName
Determining the day of the week (Monday, Tuesday, Wednesday, etc.) is a tad bit convoluted in VBScript; you have to first call the Weekday function (which returns an integer value representing the day of the week) and then call the WeekdayName function to translate that integer into a string value. In Windows PowerShell this is actually much easier; you simply get the desired date and then get the value of the DayOfWeek property. For example, this command assigns the DayOfWeek for the current date to the variable $a:
$a = (get-date).dayofweek
When you run this command and then echo back the value of $a you should get something similar the following:
Friday
What if you wanted to determine the day of the week for a date other than the current one? No problem; this command returns the day of the week for 12/25/2007:
$a = (get-date "12/25/2007").dayofweek
And here’s what you get back after running that command:
Tuesday