通过Puppet 3.0设置Powershell执行策略

时间:2012-10-09 17:01:10

标签: powershell puppet

我正在尝试使用Puppet 3.0使用以下方法为powershell 2.0设置执行策略。

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,
}

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

2 个答案:

答案 0 :(得分:1)

我不熟悉Puppet,但试试这个:

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

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

答案 1 :(得分:0)

感谢您的回复,我猜使用sysnative代替System32确实解决了这个问题。

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