Converting VBScript's Day Function

Windows PowerShell

Definition: Returns a whole number between 1 and 31, inclusive, representing the day of the month.


So, in conclusion - yes, did you have a question? You say you have an automated procedure that’s supposed to run only on the 10th and 25th of each month? You say you don't know how to use Windows PowerShell to determine the day portion of the month? Hey, no problem; this is an easy one to answer: all you have to do is call the Get-Date Cmdlet, then grab the value of the Day property. For example, this command retrieves the value of the Day property for the current date and stores that value in the variable $a:

$a = (get-date).day

When you run this command and then echo back the value of $a you should get the following, assuming you’re running the command on, say, 9/17/2006:


Return to the VBScript to Windows PowerShell home page