title: Run a powershell script from python that uses Web-Administration module
body: <p>I have a very long powershell script that I need to execute from a python script. 
  The powershell script works fine when I run it from command line, but fails when I run it from python.</p>
  
  <p>I've simplified my powershell script to the following code, which reproduces the issue.</p>
  
  <p>Powershell Script:</p>
  
  <pre><code>import-module WebAdministration
  Add-Type -Path C:\Windows\System32\inetsrv\Microsoft.Web.Administration.dll
  Set-WebConfigurationProperty '/system.webServer/proxy' -Name "enabled" -Value "true"
  </code></pre>
  
  <p>Python Script:</p>
  
  <pre><code>import subprocess
  print subprocess.check_output("powershell [pathToMyPowershellScript]");
  </code></pre>
  
  <p>When I run the powershell script from cmd.exe, it works fine and produces no output.
  When I run the python script, it produces the following error:</p>
  
  <pre><code>Set-WebConfigurationProperty : Retrieving the COM class factory for component 
  with CLSID {688EEEE5-6A7E-422F-B2E1-6AF00DC944A6} failed due to the following
  error: 80040154
  Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).
  At [pathToMyPowershellScript]:3 char:1
  + Set-WebConfigurationProperty '/system.webServer/proxy' -Name "enabled" -Value "t ...
  + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  + CategoryInfo          
   : NotSpecified: (:) [Set-WebConfigurationProperty], COMException
  + FullyQualifiedErrorId : System.Runtime.InteropServices.COMException,
    Microsoft.IIs.PowerShell.Provider.SetConfigurationPropertyCommand
  </code></pre>
  
  <p>I'm running IIS 7.5 on Windows 7 Professional (x64), with Python 2.7 and Powershell 1.0
  Any ideas?</p>