2012-10-09 42 views
1

我想用下面的配方爲使用Puppet 3.0的powershell 2.0設置執行策略。通過Puppet 3.0設置Powershell執行策略

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

回答

1

我不熟悉的木偶,但試試這個:

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}"' 
+0

我認爲它實際上不是爲我工作 EXEC { 'rolesfeatures1': \t \t命令=>「C:\ WINDOWS \ SYSTEM32 \ WindowsPowerShell \ V1.0 \ Powershell.exe -Command「& {SET-ExecutionPolicy RemoteSigned就是-Force}」」, \t \t提供商=>窗, \t \t logoutput =>真實, \t} – Maverick

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 
     } 
+0

我把這種變化從 http://docs.puppetlabs.com/windows/ running.html – Maverick