I Need help with on how to can I run PowerShell in Puppet TASK
I do not want it to run using exec cmd or Bolt.
exec { 'test':
command => '& C:\fail.ps1',
provider => powershell,
}
Check more on: write your first task in powershell. From the example above:
tasks
containing your powershell
script. e.g print.ps1
:param ($message)
Write-Output "$env:computername received the message: $message"
print.json
metadata file for the task (more on writing tasks){
"description": "Print something",
"parameters": {
"message": {
"type": "String",
"description": "Something to print"
}
},
"implementations": [
{"name": "print.ps1"}
]
}
3.1. Run the task (with bolt).
bolt task run <your-module>::print message="hello powershell" --nodes $WINNODE --modulepath ./modules --no-ssl
The result:
Started on localhost...
Finished on localhost:
Nano received the message: hello powershell
{
}
Successful on 1 node: winrm://vagrant:vagrant@localhost:55985
Ran on 1 node in 3.87 seconds
3.2. Run the task (with Puppet Console UI)
You would need to install the puppet module (where you have developed the task), by either adding it to the Puppetfile or installing it manually.
After that, you login to Puppet Console UI and run the task.