Contact Info

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

Get-Date - Powershell 1.0 CmdLet

Microsoft Windows PowerShell is a command-line shell and scripting tool based on the Microsoft .NET Framework. It is designed for system administrators, engineers and developers to control and automate the administration of Windows and applications.

More than hundred command-line tools (so called "cmdlets") can be used to perform system administration tasks and Windows Management Instrumentation (WMI). These cmdlets are easy to use, with standard naming conventions and common parameters, and standard tools for piping, sorting, filtering, and formatting data and objects.


Get current date and time


-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