Maverick
Maverick

Reputation: 1303

Setting Powershell Execution Policy Through Puppet 3.0

I am trying to set the execution policy for powershell 2.0 using Puppet 3.0 with the following recipe.

exec { 'rolesfeatures1':
command => 'C:\Windows\System32\cmd.exe /c C:\Windows\System32\WindowsPowerShell\v1.0\Powershell.exe Invoke-Command {Set-ExecutionPolicy RemoteSigned}',
provider => windows,
logoutput => true,
}

or

exec { 'rolesfeatures1':
command => 'C:\Windows\System32\WindowsPowerShell\v1.0\Powershell.exe Invoke-Command {Set-ExecutionPolicy RemoteSigned}',
provider => windows,
logoutput => true,
}

Upvotes: 1

Views: 1374

Answers (2)

Maverick
Maverick

Reputation: 1303

Thanks for replying that i guess using sysnative in replacement of the System32 did fix the issue.

exec {'executionpolicy':
        path => 'C:\Windows\sysnative\WindowsPowerShell\v1.0', #Puppet redirects to SysWOW64 by default
        command => 'Powershell.exe -Command "& {Set-ExecutionPolicy Unrestricted}"',
        logoutput => true
        }

Upvotes: 0

Keith Hill
Keith Hill

Reputation: 201622

I'm not familiar with Puppet but try this:

command => 'C:\Windows\System32\WindowsPowerShell\v1.0\Powershell.exe -Command {Set-ExecutionPolicy RemoteSigned}'

or

command => 'C:\Windows\System32\WindowsPowerShell\v1.0\Powershell.exe -Command "& {Set-ExecutionPolicy RemoteSigned}"'

Upvotes: 1

Related Questions