通过 Puppet 3.0 设置电源外壳执行策略



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

exec { 'rolesfeatures1':
command => 'C:WindowsSystem32cmd.exe /c C:WindowsSystem32WindowsPowerShellv1.0Powershell.exe Invoke-Command {Set-ExecutionPolicy RemoteSigned}',
provider => windows,
logoutput => true,
}

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

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

command => 'C:WindowsSystem32WindowsPowerShellv1.0Powershell.exe -Command {Set-ExecutionPolicy RemoteSigned}'

command => 'C:WindowsSystem32WindowsPowerShellv1.0Powershell.exe -Command "& {Set-ExecutionPolicy RemoteSigned}"'

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

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

最新更新