Query Powershell Error Object Time Occured
Solution 1:
As far as I know there is no date-time that is part of the error object. If you want the datetime, just add a Get-Date
into your catch
block or whatever and add it to your output, logs whatever output method you are using for the rest of the error.
The 'o' format has lots of precision and useful format for log files.
PS C:\users> Get-Date -Format o
2017-02-27T11:57:31.3946789-08:00
Solution 2:
PowerShell error objects don't contain date/time information.
Source: Windows PowerShell Error Records
The InvocationInfo class doesn't contain that information either.
If you want that metadata, you'll need to put it somewhere when you catch
a terminating error. This won't help too much with non-terminating errors, though.
It might help if you more fully explain your use case.