title: How to resolve Class not registered error for PowerShell Script in InstallShield 2015?
body: <p>I have a PowerShell script which works fine if executed manually but when i try to execute it by creating a function in InstallShield 2015, it fails with below error -</p>
  
  <blockquote>
    <p>get-webconfiguration : Retrieving COM class factory for component with
    CLSID 80040154 class not registered 
    {688EEEE5-6A7E-422F-B2E1-6AF00DC944A6} FAILED DUE TO THE FOLLOWING
    ERROR : 80040154 Class not registered (Exception from HRESULT:
    0X80040154 (REGDB_E_CLASSNOTREG))</p>
  </blockquote>
  
  <p>Below is the InstallShield function which is called during installation to update the Physical path of the Virtual application in IIS.</p>
  
  <pre><code>function VirtualAppPowershell()
  
      STRING szMsg, szCmdLine, szAppPath1, szDir;
      NUMBER nResult;
      STRING szFile, svDir;
  
  begin                               
  
      try
          szAppPath1 = "powershell.exe";
          //szAppPath1 = "powershell_ise.exe";
  
          szDir = TARGETDIR;
  
          svDir = TARGETDIR + "Demo\\Script\\";
          szCmdLine = "-File .\\VirtualAppPathChange.ps1 \"" + svDir +"\\\""; 
  
  
          StrRemoveLastSlash (svDir);
  
          ChangeDirectory(svDir);
  
          szMsg = "Updating PhysicalPath of Virtual application";                                    
  
          SdShowMsg ( szMsg , TRUE );
          Delay (5);       
          nResult = LaunchAppAndWait (szAppPath1, szCmdLine, WAIT|LAAW_OPTION_MINIMIZED);
          SdShowMsg ( szMsg , FALSE );  
  
      catch
          WriteLogAsError(FALSE, Err.Number, Err.Description);
          Err.Raise();
      endcatch;
  
      return nResult;
  end;  
  </code></pre>
  
  <p>Here is the code of PowerShell Script as well for reference-</p>
  
  <pre><code>#Code to get PhysicalPath of Virtual application
  $WebClientPath=(get-webapplication DemoApp).PhysicalPath
  
  # Code to get Installation Directory path
  $CommonNode=Get-ItemProperty -Path Registry::HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Demo\Platform\Common
  $InstallationDir=$CommonNode.InstallationDir
  
  #Appended new foldername to $Path1
  $Path1= $InstallationDir + "Test\"
  
  #Appended old foldername to $Path2
  $Path2= $InstallationDir + "Dem\"
  
  
  # Code to get Version of application
  $PlatformNode=Get-ItemProperty -Path Registry::HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Demo\Platform
  $Version=$PlatformNode.VERSION
  
  if($Version -ge "7.3.0.0")
  {
      Set-ItemProperty 'IIS:\Sites\Default Web Site\DemoApp' -Name physicalPath -Value "$Path1"
  }
  else
  {
      Set-ItemProperty 'IIS:\Sites\Default Web Site\DemoApp' -Name physicalPath -Value "$Path2"
  }
  </code></pre>
  
  <p>Note - <strong>My OS is 64 bit.</strong></p>