some powershell/IIS commands not running under puppet?

asked 2016-02-22 14:30:23 -0500

lquantz gravatar image

This is a strange one. We use Powershell and puppet, which has done great work for us. But in one instance we're trying to make some IIS changes and it's not working-- but running the script in the command line does.

We're trying to enable Windows Authentication on our site in a script like so:

param([string] IIS_Site)

$tempfile = "c:\temp\pstemp.txt"
Import-Module WebAdministration

Try
{
    echo "entering try-catch" >> $tempfile
    Set-WebConfigurationProperty -Filter "/system.webServer/security/authentication/windowsAuthentication" -Name Enabled -Value True -PSPath IIS:\ -location $IIS_Site

}
Catch
{
    echo "error: " $_.Exception.Message  >> $tempfile
}

When I run puppet agent -t the script downloads and runs, but I get this error on the Set-WebConfiguration bit, as shown in the catch statement output:

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

If I run the same script from PowerShell in the command line (the same command line instance as I run puppet agent -t from), the change takes effect no problem.

Does anyone have an idea what might be going on? We use a number of powershell scripts in Puppet and they all work fine.

edit retag flag offensive close merge delete

Comments

Hi, it's a bit delayed, but do you have more information on what version of the powershell module you're using?

GlennSarti gravatar imageGlennSarti ( 2016-06-30 10:59:07 -0500 )edit

Same problem here: Module is standard webadministration module coming with Windows 2008 R2. It also looks like when trying to load reflection assembly Microsoft.Web.Administration it also fails at same point.

michal.lukowicz gravatar imagemichal.lukowicz ( 2016-09-13 13:22:29 -0500 )edit