Why does Get-Date seem to return DateTime objects, but the BinarySerializer indicate it returns a PSObject? Why does Get-Date seem to return DateTime objects, but the BinarySerializer indicate it returns a PSObject? powershell powershell

Why does Get-Date seem to return DateTime objects, but the BinarySerializer indicate it returns a PSObject?


Based on MSDN:

PSOobject Class:

Encapsulates a base object of type Object or type PSCustomObject to allow for a consistent view of any object within the Windows PowerShell environment.

( get-Date '2002-03-23' ) -IS [psobject]True( get-Date '2002-03-23' ) -IS [datetime]True[datetime]( get-Date '2002-03-23' ) -IS [datetime]True[datetime]( get-Date '2002-03-23' ) -IS [psobject]False


Every object in PowerShell is actually wrapped mostly transparently in a PSObject. I say mostly transparently, because there are more than a few bugs in PowerShell that omit to remove the wrapper before leaking the object to another API. This causes all sorts of issues, much like the one you see now. Search connect.microsoft.com/powershell for PSObject wrapper. I believe this is no longer an issue in v3 with the new DLR-based engine.