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.
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.