繁体   English   中英

通过Puppet 3.0设置Powershell执行策略

[英]Setting Powershell Execution Policy Through Puppet 3.0

我正在尝试通过以下配方使用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,
}

我不熟悉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}"'

感谢您的答复,我想使用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
        }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM