我正在尝试使用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,
}
答案 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
}