Can you please tell me why one of these lines of code works and the other does not?
I am passing an ADUser object with LastLogonTimeStamp property added, to the DateTime Parse method. If I pass it directly, if errors, saying the 'input string was not in correct format'. If I use a ForEach 'loop' (even though in this test case, I am only passing one object not a collection of them--but I will be doing that), the method performs as expected.
In both cases I'm passing the same object, with same property value referenced. Works:
get-aduser user001 -property lastlogontimestamp | foreach {Get-Date Date ([DateTime]::FromFileTime([Int64]::Parse($_.LastLogonTimeStamp)))} Sunday, August 16, 2015 8:01:27 PM
Fails:
get-aduser 9aubyt001 -property lastlogontimestamp | Get-Date Date ([DateTime]::FromFileTime([Int64]::Parse($_.LastLogonTimeStamp))) Exception calling "Parse" with "1" argument(s): "Input string was not in a correct format."At line:1 char:1Thanks.