title: How do Powershell query interface on a COM object
body: <p>I created a COM object using Powershell:</p>
  
  <pre><code>$obj = new-object -com MyLib.MyObj
  </code></pre>
  
  <p>Then I need to query the interface <code>"MyLib.MyInterface"</code> on that object, but I have no idea how to do it with PowerShell.</p>
  
  <p>In order word
  suppose I have the below C++ code</p>
  
  <pre><code>CComPtr&lt;IInterface1&gt; pInterface1;
  CComPtr&lt;IInterface2&gt; pInterface2;
  pInterface1-&gt;CoCreateInstance(CLSID_XXXX);   //in PowerShell: $obj = new-object -com MyLib.MyObj
  pInterface1-&gt;QueryInterface(IID_YYYY, &amp;pInterface2); //how to do this in PowerShell?
  </code></pre>
  
  <p>How do I do the same job with Powershell</p>
  
  <p>Any comments?</p>
  
  <p>Thanks</p>