Monday, 18 September 2017

Get-Printer StartTime and UntilTime

The Windows PowerShell Get-Printer cmdlet provides a start and finish time for printer availability but confusingly this value is returned as an integer value.

More confusingly this is stored as a value of minutes from midnight GMT so if you print server is in GMT -5 and has a available from time of midnight you'll see the StartTime of 300.

If you'd like to convert the time to a DateTime that is more understandable that reflects what is seen in the UI try the following

$baseTime = [System.DateTime]::MinValue.AddDays(1)
$baseTime = $baseTime.AddHours([System.TimeZoneInfo]::Local.BaseUtcOffset.TotalHours)
$baseTime = $baseTime.AddMinutes(150)

No comments:

Post a Comment