Date and time manipulation
When you are scripting, there are times where you may need to get the date and time of a system. PowerShell offers the get-date
cmdlet, which provides the date and time in many different formats of your choice.
To obtain the date object, execute the following command:
$time = get-date $time
The output of this is shown in the following screenshot:
The standard get-date
cmdlet, without any triggers, will generate the long date and time format. When you store the date
object in a variable, it is important to remember that the data captured from the cmdlet is a snapshot in time. You'll have to call the get-date
cmdlet again to ...
Get Mastering Windows PowerShell Scripting now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.