Contact Info

Crumbtrail » Administration » Powershell » Powershell 1.0 » Get-Date

Get-Date - Powershell 1.0 CmdLet

ActiveXperts Network Monitor ships with integrated Powershell scripts to monitor complex network. The scripts run out of the box
Download the ActiveXperts Network Monitor FREE version now »


Get current date and time

Get-Date [[-date] DateTime]
         [-displayHint {Date | Time | DateTime}]
           {[-format string] | [-uFormat string]}
              [-year int] [-month int] [-day int] [-hour int]
                 [-minute int] [-second int] [CommonParameters]

-date DateTime
        By default, Get-Date returns the current system date and time.
        The -date parameter allows you to specify
        (usually via the pipeline) a specific date and time. 

   -displayHint DisplayHintType
        Display only the Date, only the Time or the DateTime.
		 This does not affect the DateTime object that is retrieved.

   -format string
        Display the date and time in the .NET format
        as indicated by String representing a format specifier. 
   -uFormat string
        Displays the date and time in Unix format.

   -year -month -day -hour -minute -second 
        These allow you to set individual items to be displayed in place
        of the current date/time. e.g. you could set the time to 12:00

       -Verbose, -Debug, -ErrorAction, -ErrorVariable, -OutVariable.

Retrieve the current date and time, but display only the date:

PS C:\>get-date -DisplayHint date

Retrieve the current date and time, display as a General short date/time:

PS C:\>get-date -format g

Display the day of the year:

PS C:\>(get-date).dayofyear

Display daylight savings and UTC:

PS C:\>$a = get-date

Display the bios date of a remote machine using WMI:

PS C:\>$a = get-wmiobject win32_bios -computer SERVER64
$a | format-list -property Name, @{Label="BIOS Date "; `

The backtick character (`) is the line continuation character