Quantcast
Channel: PowerShell.org » All Posts
Viewing all articles
Browse latest Browse all 13067

Reply To: Converting WMI Date and Time

$
0
0

By the sound of it, you were using code like this:

(gwmi namespacegoeshere -ComputerName ‘test’).endtime |
ForEach-Object {
    [System.Management.ManagementDateTimeConverter]::ToDateTime($_.endtime)
}

You’re essentially trying to read the value of $object.endtime.endtime , in that code (which will always be null). One or the other of the instances of “.endtime” in the code would have to go; in this case, it doesn’t matter which one. In general, though, I would recommend keeping the one inside the loop (so you still have access to any other properties of the objects returned by Get-WmiObject):

gwmi namespacegoeshere -ComputerName ‘test’ |
ForEach-Object {
    [System.Management.ManagementDateTimeConverter]::ToDateTime($_.endtime)
}

Viewing all articles
Browse latest Browse all 13067

Trending Articles