Ask Your Question

what is fact syntax in powershell scripts?

asked 2015-04-06 11:27:19 -0500

richnavis gravatar image

updated 2015-04-06 12:19:10 -0500

I've created a few custom fax that I've verified are working on my windows client by using the facter -p command. However, I'm trying to use these facts inside a module using the exec command with the powershell provider. However, it doesn't appear that my powershell is able to read the facts. See example below:

myfact="hello" exec { 'mytest': command => 'add-content -path c:\mytest.txt -value "this is my fact, $::myfact" ' provider = > powershell }

In my text file I only get "this is my fact,".... The fact does not show up.

Any help?

edit retag flag offensive close merge delete


${::myfact} (with curly brackets)?

Kai Burghardt gravatar imageKai Burghardt ( 2015-04-06 12:13:06 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2015-04-06 13:16:41 -0500

richnavis gravatar image

updated 2015-04-06 13:17:29 -0500

I see what I was doing wrong... I had single quoted my powershell line.. preventing puppet from interpolating it's variables... enclosing my powershell in double quotes and removing my single quotes did the trick... now, if someone could tell me what characters need to be escaped in an EXEC command line.. I'll will be set. Thanks Kai for your response..

edit flag offensive delete link more


Yeah, now I see it too. <pre><code> and line formatting/alignment would have made it more obvious.

Kai Burghardt gravatar imageKai Burghardt ( 2015-04-06 15:36:44 -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


Asked: 2015-04-06 11:27:19 -0500

Seen: 441 times

Last updated: Apr 06 '15