Converting VBScript's MonthName Function

Windows PowerShell

Definition: Returns a string indicating the specified month


Sometimes all you want to know is that we’re in month number 9; at other times you’d prefer to know the name of the month (e.g., September). In Windows PowerShell you can determine the name of the month by using the Get-Date Cmdlet and then using the -f formatting parameter and the value MMMM. In other words, this command will retrieve the name of the month for the current month and store that value in the variable $a:

$a = get-date -f "MMMM"

When you run this command and then echo back the value of $a you should get the following (depending on the actual month):


Return to the VBScript to Windows PowerShell home page