Ask Your Question

some powershell commands not running under puppet?

asked 2016-02-22 14:31:29 -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

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

    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, some permission thing maybe? We use a number of other powershell scripts in Puppet and they all work fine.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2016-02-22 18:10:17 -0500

Conventional gravatar image

I think the backslashes "\" may make this different from other Puppet Manifests. This PowerShell script may work fine when ran without Puppet. For the three backslashes (two in the $tempfile path and one in the "-PSPath IIS:" section, I would replace them with one of the following: 1) forward slashes / 2) double back slashes \

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2016-02-22 14:31:29 -0500

Seen: 92 times

Last updated: Feb 22 '16