I am running the follwoing script for a remote computer. PS remoting is enabled on remote computer
Function GetUpTime { param([string] $LastBootTime) $Uptime = (Get-Date) - [System.Management.ManagementDateTimeconverter]::ToDateTime($LastBootTime)"Days: $($Uptime.Days); Hours: $($Uptime.Hours); Minutes: $($Uptime.Minutes)" } $OperatingSystem = Get-WmiObject Win32_OperatingSystem -ComputerName "MX212DCCIP02" -ErrorAction SilentlyContinue $Uptime = GetUptime( $OperatingSystem.LastBootUpTime
)
Write-Host $Uptime
Getting the below error. Please somebody help
Exception calling "ToDateTime" with "1" argument(s): "Specified argument was out of the range of valid values. Parameter name: dmtfDate" At C:\temp\test.ps1:4 char:84+ $Uptime = (Get-Date) - [System.Management.ManagementDateTimeconverter]::ToDateTime <<<< ($LastBootTime)+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException+ FullyQualifiedErrorId : DotNetMethodException
↧
Script error
↧