Ask Your Question

Handling Windows Redirection Operators

asked 2015-06-23 12:29:09 -0500

tek0011 gravatar image

I am attempt something as basic as:

  exec { "windows redirection operator test" :
    command   => "sc query W32Time > C:\\ProgramData\\PuppetLabs\\redirection.log",
    path      => $::path,

The command, when executed outside puppet works great. However, once puppet executes it, it fails to create a log file. There isnt much out there regarding windows redirection operators with puppet, so I figured I would ask here. Any ideas on how to make this redirect the output to a file? Ive tried numerous syntax with no luck yet.


edit retag flag offensive close merge delete


Are there any messages in the Event Viewer? Does the user running the Puppet agent service have access to the target directory to create the log file?

GregLarkin gravatar imageGregLarkin ( 2015-06-24 00:27:00 -0500 )edit

Nothing in the event viewer. Puppet sends the command just fine, it just doesnt handle the redirect operator. I have tried using >> to append to an already existing log file, that fails. I have tried > to have it create a new log file, that fails. It can handle piping | just fine, though.

tek0011 gravatar imagetek0011 ( 2015-06-26 08:49:37 -0500 )edit

puppet agent is running as local admin

tek0011 gravatar imagetek0011 ( 2015-06-26 08:50:04 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2015-06-26 09:27:46 -0500

tek0011 gravatar image

updated 2015-06-26 09:28:08 -0500

  exec { "windows redirection operator test" :
    command   => "C:\\Windows\\System32\\cmd.exe /c sc qc \"W32Time\" > C:\\ProgramData\\PuppetLabs\\redirection.log",
    path      => $::path,

Apparently I was used to | working without calling cmd. It seems the other redirect operators require calling cmd first.

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: 2015-06-23 12:29:09 -0500

Seen: 82 times

Last updated: Jun 26 '15