Ask Your Question

Running Powershell From Puppet, cmd-lets not recognised.

asked 2013-10-18 09:11:25 -0500

LegoYoda gravatar image

Hi everyone.

I'm just starting to have a go with Puppet (opensource version for the moment) but I'm finding it tricky to get my head around why certain things happen the way they do. The big issue I have at the moment is that I can't seem to get powershell scripts to execute correctly. Something odd happens when puppet runs them (they DO execute) compared to when they are run independently (but using the same scripts). I'll show the example:

I am trying to manipulate a server so it installs / checks for NFS and some shares ... (more)

edit retag flag offensive close merge delete


Did you check the execution policy?

louis gravatar imagelouis ( 2013-10-20 17:42:08 -0500 )edit

Yeah, I thought that might be the case so I hard changed it to "unrestricted" in the registry. The script is kicking off as the "simple" parts (creating files as ...(more)

LegoYoda gravatar imageLegoYoda ( 2013-10-21 02:32:37 -0500 )edit

3 Answers

Sort by ยป oldest newest most voted

answered 2013-10-21 07:34:57 -0500

LegoYoda gravatar image


Looks like it's actually because the Puppet client for Windows is 32-bit ? Basically Invoking PS scripts from the client caused them to be run in Powershell 32-bit mode. The cmd-lets I was using to administer Windows are from a 64-bit only module and, therefore were failing. Even if you specify the path to the 64-bit PS.exe Windows runs it in the 32-bit context (AFAIK).

Inserting the code from this article: in to the top of the script that Puppet executes forces the remainder of the PS code to be run in a 64-bit instance.

edit flag offensive delete link more


puppet runs with a 32-bit version of ruby. When you execute `c:\windows\system32\...\powershell.exe` the OS will redirect that to the 32-bit version. Which is one reason why ...(more)

joshc gravatar imagejoshc ( 2013-10-30 23:21:31 -0500 )edit

answered 2013-10-21 23:00:03 -0500

joshc gravatar image

You should use the powershell module: . It provides a powershell provider for the exec type, and it automatically runs the 64-bit version of powershell when running on an x64 OS, as well as setting the execution policy, etc.

edit flag offensive delete link more

answered 2013-10-20 17:43:41 -0500

louis gravatar image

I have the following resource to make sure my policy settings are always the same.

 exec { $pkg:
    command   => 'Powershell.exe -ExecutionPolicy RemoteSigned -File C:\Temp\PSSettings.ps1',
    logoutput => true,
    require   => File[$pkg],
    unless    => 'Powershell.exe Get-ExecutionPolicy | C:\Windows\System32\findstr.exe RemoteSigned'
edit flag offensive delete link more


That's a very useful bit of code there thanks. Unfortunately it's not the route of my issue. the scripts run and they are not getting hit by the ...(more)

LegoYoda gravatar imageLegoYoda ( 2013-10-21 05:06:55 -0500 )edit

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: 2013-10-18 09:11:25 -0500

Seen: 1,245 times

Last updated: Oct 21 '13