
This technique is shown here.Īll three of the previous examples, however, use the same calendar-the Gregorian calendar. The easiest way to create a specific date is to cast a string to the DateTime object. PS C:\> Get-Date -Month 3 -Day 15 -Year 2012 This command and the output associated with the command are shown here. It is definitely easier to read the Get-Date command. I am not certain it is any easier, but it is a bit less typing. Of course, I can do the same thing by using the Get-Date cmdlet. PS C:\> New-Object system.datetime -ArgumentList 2012,3,15 Using Windows PowerShell to create a new instance of the System.DateTime class by passing the year, month, and day is shown here. To create a new DateTime object and specify the year, month, and day, requires me to use a particular constructor. As a matter of a fact, MSDN lists 11 different constructors on the System.DateTime details page. NET Framework class, there are several different constructors. NET Framework class I want to use, and I pass the arguments for the constructor to the ArgumenLlist parameter. To do this, I use the New-Object cmdlet to specify the name of the. If I want to create a specific date, I can use the constructor for the System.DateTime. NET Framework classes are fun to play with. If you want to work with calendars in Windows PowerShell, perhaps you should also beware of the Ides of March-or at least be aware of how to work with different calendar types.Īnyway, the. For me, I think back to the play by William Shakespeare, Julius Caesar. For the Scripting Wife, it means March Madness is underway. In addition, there have been a decent amount of questions via the email alias about the series of live meetings in addition to the 2012 Scripting Games. It is encouraging to see the level of interest in this series.

The series has been a lot of fun, and the feedback so far has been great. Today is day four of my PowerShell Essentials for the Busy Admin series of webcasts.

Microsoft Scripting Guy, Ed Wilson, is here. Summary: Learn about using Windows PowerShell and specifying different calendar types to use with dates.
