Hi,
I need further help on this so posting my query here.
I am trying to fetch Date and time from this last entry of host vmkrnel log like below but I am getting the exception mentioned below. Please let me know how can I convert it to Date and Time format so that I can find out the time difference with the current date and time.
$lastLine = Get-Log -Key vmkernel -VMHost $esx | Select @{N='VMHost';E={$_.Host.Name}},@{N='LastLine';E={$_.Entries[$_.LastLineNum - 1]}}
$lastDateTime = $lastLine.LastLine.Split("Z ")[0].ToDateTime($_)
Exception calling "ToDateTime" with "1" argument(s): "String was not recognized as a valid DateTime."
At D:\PNF-Morning-Checks\VSAN-MorningCheck-Daily.ps1:761 char:6
+ ... $lastTime = $lastLine.LastLine.Split("Z ")[0].ToDateTime( ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : FormatException