Instead of typing Get-ItemProperty, all you need to do is type GP. Don??™t you
love aliases?
Working with Dates and Times
Knowing dates and times and performing calculations using dates and times are necessities
for every administrator. Time has many uses and is significant in almost all aspects
of computing. Fortunately, PowerShell comes with a rich set of date and time??“related
features to help you tackle these tasks with relative ease. It??™s not surprising that the
cmdlet that handles data and time is called Get-Date. (Perhaps Get-DateTime might be
more appropriate, but just be happy you have less to type.) Running Get-Date by itself
Figure 13-6. Results of Get-ItemProperty on a registry key
455 Chapter 13: Windows PowerShell
returns the current day, date, and time. If you want to return just the date or time, you
can run either of the following commands, respectively:
Get-Date -displayhint date
Get-Date -displayhint time
The date and time are displayed in the current time zone configured on your server.
If you are a global company, sometimes it works best when everyone expresses dates
and times in terms of Universal Time Code (UTC). This isn??™t a problem since the Get-
Date cmdlet has a ToUniversalTime method built in to do this for you. This can be
displayed by running the following:
(Get-Date).ToUniversalTime()
Perhaps one of the biggest date and time??“related events in computers after Y2K was
the issue of daylight savings time.
Pages:
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487