Chef Powershell Run from File

chef-infra, windows

Solution

You can call unsigned powershell scripts directly within `powershell_script`, as long as your execution policy allows it, which Chef does by default.

powershell_script "run some script" do
  code "c:/something/script.ps1"
end

If you want chef to deploy the script too, you can do it from the `/files` section of the cookbook with `cookbook_file`.

Problem

Using chef's powershell_script provider how would I reference a file stored on the chef server instead of having the code defined in the same file? Basically how can I call on a .ps1 located on the server from a chef client?

Original source