Thanks Juan. Couple of questions on your reply.
1. In my case would it be the following: command => "powershell.exe -ExecutionPolicy ByPass -File file.ps1 ${dnsforwarders}" # or does this need to be adjusted? 2. How do i do the same with the fact that I am using templates, and thus they are stored on Puppet and passed to the server. I am not storing the powershell files on the agent server. Is there a way to do something like the following: command => template ($forwarder_execute) ${Param1}, # On Thursday, October 9, 2014 3:35:59 PM UTC-4, Juan Andres Ramirez wrote: > > if you want execute a powershell file: > > command => "powershell.exe -ExecutionPolicy ByPass -File file.ps1 > ${param1}" > > On Thursday, October 9, 2014 4:22:14 PM UTC-3, Paul Ponzeka wrote: >> >> I am using Puppet installed with the powershell module. I am struggling >> with how to pass a puppet variable through to powershell. For instance I >> have the following in my module *init.pp* file: >> >> class windows_dns( >> >> $forwarders = '1.1.1.1' >> >> ) { >> anchor { 'windows_dns::begin': } -> >> class{'windows_dns::install': } -> >> class{'windows_dns::config': } -> >> class{'windows_dns::service': } -> >> anchor { 'windows_dns::end': } >> >> } >> >> >> Then in my *config.pp* file I have: >> >> class windows_dns::config { >> >> case $kernelmajversion { >> 6.3: { >> $forwarder_execute = >> 'windows_dns/setdnsforwarders.ps1' >> $forwarder_check = 'windows_dns/checkdnsforwarders.ps1' >> $dnsforwarders = $windows_dns::forwarders >> >> } >> 6.1: { >> $forwarder_execute = >> 'windows_dns/setdnsforwarders_legacy.ps1' >> $forwarder_check = 'windows_dns/checkdnsforwarders_legacy.ps1' >> >> } >> } >> >> exec { 'forwarderscreate': >> >> command => template ($forwarder_execute), >> unless => template ($forwarder_check), >> provider => powershell, >> logoutput => true, >> >> } >> >> I have stored as a template in the manifest a powershell script file as: >> >> $dnsforwarders | out-file C:\test.log >> >> I obviously want to use a more complex output. I tried adding a >> parameter to the top of my powershell script but dont understand how to >> pass that as an option to puppet. >> >> The variable passes through fine. I tested by changing the command to >> *command=> >> template ($dnsforwarders)* and i of course got an error from puppet >> about it not being able to find the template named *1.1.1.1* in the >> manifest. I just dont know how to pass this through to the shell. >> > -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/5eab4876-2e68-4d3a-a6cd-a931b0daa5a4%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.