Exchange 2010 PowerShell 2.0 and C# deserialization problem RRS feed

  • Question

  • User1686640674 posted

    I'm trying to use C# to create scripts wrapping calls to Exchange 2010 methods such as Get-Mailbox and Get-MailboxStatistics.

    I'm using the 2.0 DLL file from PowerShell and most calls give me no problem at all. I even get results back from Get-Mailbox.

    The problem is that they all are PSObject and the only way to access properties is via the deserialized string properties, i.e.


    Which are pretty much all strings. In Exchange 2007 and PowerShell 1, I'd do myPSObject.BaseObject as MailboxStatistics.

    This seems to be related to the fact that PowerShell 2.0 is remoting into the destination server, as per http://blogs.msdn.com/powershell/archive/2010/01/07/how-objects-are-sent-to-and-from-remote-sessions.aspx

    There has to be a way to get the objects back properly, otherwise the whole .NET DLL thing for PowerShell is rendered useless since all types that aren't primitives or natively supported by PowerShell serialization cannot be used.

    Thursday, January 14, 2010 3:06 PM

All replies