PowerShell: how to convert a COM object to an .NET interop type?
问题 As described in my question Create ISO image using PowerShell: how to save IStream to file?, in PowerShell I create an IStream object as follows: $is = (New-Object -ComObject IMAPI2FS.MsftFileSystemImage).CreateResultImage().ImageStream This object is of (PowerShell) type System.__ComObject . And somehow PowerShell knows that it is an IStream : PS C:\> $is -is [System.Runtime.InteropServices.ComTypes.IConnectionPoint] False PS C:\> $is -is [System.Runtime.InteropServices.ComTypes.IStream]