title: Checking UPTIME of remote server in Powershell
body: <p>I am trying to retrieve the UPTIME of a remote server using the below code snippet in my script.</p>
  
  <pre><code>$lastboottime = (Get-WMIObject -Class Win32_OperatingSystem -ComputerName     $server -Credential $altcreds -ErrorAction SilentlyContinue).LastBootUpTime
  $sysuptime = (Get-Date) - [System.Management.ManagementDateTimeconverter]::ToDateTime($lastboottime)
  $uptime = "   UPTIME           :    $($sysuptime.days) Days, $($sysuptime.hours) Hours, $($sysuptime.minutes) Minutes, $($sysuptime.seconds) Seconds"
  </code></pre>
  
  <p>I get the below error when executing the script:</p>
  
  <pre><code>Exception calling "ToDateTime" with "1" argument(s): "Specified argument was out of the range of valid values.
  Parameter name: dmtfDate"
  </code></pre>
  
  <p>I am unable to determine what the error message is what arguments are required?</p>
  
  <p>Thanks!</p>