Ask Your Question

Puppet not running powershell script on Windows

asked 2014-09-08 08:38:31 -0500

xkcd gravatar image

updated 2014-09-15 15:24:25 -0500

The puppet agent on my Windows VMs is not running a powershell script. I have tested it with a very simple script as well. The script is stored on C drive as test.ps1. Its contents are as follows:-

"$(Get-Date -format F)" | Out-File C:\z.txt -Encoding ASCII

When I run this as ./test.ps1 from the powershell it works fine and the file z.txt is created. But for some reason puppet doesn't run this. The contents of my site.pp are:-

exec { "Run Script":
        command => 'C:/Windows/System32/WindowsPowerShell/v1.0/powershell.exe -Executionpolicy Unrestricted -File c:/test.ps1',
        logoutput => true,
        refreshonly => true,

And the output of "puppet agent -t" from the VM itself is:-

C:\Users\Administrator>puppet agent -t
Info: Retrieving pluginfacts
Warning: Copying owner/mode/group from the source file on Windows is deprecated;
 use source_permissions => ignore.
   (at C:/Program Files (x86)/Puppet Labs/Puppet/puppet/lib/puppet/type/file/sou
rce.rb:120:in `each')
Info: Retrieving plugin
Info: Caching catalog for f9881998-7fdf-4e96-a784-d9690fcd5495
Info: Applying configuration version '1410182959'
Notice: Finished catalog run in 0.42 seconds

So it seems to me that there is no error anywhere but still the powershell script doesn't run. Any ideas what am I doing wrong?

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2014-09-10 04:07:37 -0500

GlennSarti gravatar image
  1. Have you tried using the Puppetlabs supported powershell provider for exec?
  2. The refreshonly attribute means it will only process that resource if another resource is modified. It doesn't appear that it depends on anything else, or perhaps you haven't posted all of the relevant manifests.
edit flag offensive delete link more

answered 2014-09-30 13:42:45 -0500

Iristyle gravatar image

updated 2014-09-30 13:43:01 -0500

  • Definitely use the PowerShell module on the forge ->
  • Always try to ensure idempotency when running a powershell script by supplying an unless or onlyif -
  • Note that the module will work properly on both 32-bit and 64-bit Windows, whereas the exec method that you're using can behave differently on Puppet 32-bit or Puppet 64-bit (first introduced in Puppet 3.7)
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: 2014-09-08 08:38:31 -0500

Seen: 1,415 times

Last updated: Sep 30 '14