Jenkins powershell plugin Class not registered error in windows server 2008

1.4k views Asked by At

I have a example.ps1 file in which i am trying to stop a website in IIS using Stop-Webitem "somesite" command, when i run this in powershell command window it works fine, but when i try to call same file using jenkins powershell plugin i get the following exception

Stop-Webitem : 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)).

I googled and found that the issue is with the plugin invoking x86 version of powershell and registry problem, but could not find any solution on how to fix it. Any help is appreciated.

2

There are 2 answers

1
Sheiky On

I could not fix the above issue but i found a workaround to run my powershell script, i wrote a Ant task as shown below

<project name="tester"> <target name="IISreset" description="Resets the IIS website" > <exec executable="powershell" failonerror="true" output="iisout.log"> <arg line="-ExecutionPolicy RemoteSigned" /> <arg line="-File D:\test\reset.ps1" /> </exec> </target> </project>

saved it as ps.xml file and from jenkins i used "Invoke Ant" as build step and passed the required parameters and done. Works smooth!!

Before doing this i also tried "Execute windows batch command" buildstep in jenkins and gave the following command powershell powershell -NoExit -File c:\scripts\script.ps1 even this did not work for me. So finally decided to stick with Ant task.

If any one comes across a solution to fix the jenkins Powershell plugin issue, please do share it.

Hope the above solution helps if someone is facing similar problem.

0
user2767141 On

because it is running powershell(x86), rather powershell 64 bit. ref: http://forums.asp.net/t/1119052.aspx?Retrieving+COM+class+factory+failed+due+to+the+following+error+80040154

The VSS Interop is a managed assembly using 32-bit Framework and the dll contains a 32-bit COM object. If you run this COM dll in 64 bit environment, you will get the error message.

I guess you are running jenkins with 32bit java (the buildin java). you just need config jenkins.xml to use 64bit java, which should call correct version of powershell. (that solution works for me)