Ask Your Question

powershell add-content command not working

asked 2015-04-06 19:36:19 -0500

richnavis gravatar image

I'm trying to use the exec type with the powershell provider to add content to a windows file. The powershell command is as follows, and works fine from the command prompt. add-content -path c:\utils\test -value 'testing'

However, putting this in a module.. doesn't do anything. I get success message when running puppet agent --test, even though the file never gets created, and therefore no value inside. Even If I create the file manually, the puppet code with powershell doesn't update the file.. something wrong with what I'm doing? or with the powershell provider? Here's the success message...

add-content -path c:\utils\test -value 'testing' Notice: /Stage[main]/All_servers/Exec[test]/returns: executed successfully

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2015-04-06 19:57:00 -0500

richnavis gravatar image

So.. this is the second "problem" I've had with the format of my powershell line in the puppet module. Just because it works in powershell doesn't mean it will work in puppet. In THIS particular case, the single quotes needed to be escapaed with a tick (`). sigh.. If anyone has a guide to what needs to be escaped in an EXEC command.. I will bake you some brownies..

edit flag offensive delete link more


I also found that putting a "TAB" in texts will cause a problem.. use spaces instead

richnavis gravatar imagerichnavis ( 2015-04-07 20:29:03 -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: 2015-04-06 19:36:19 -0500

Seen: 447 times

Last updated: Apr 06 '15