Fix to set Powershell's ExecutionPolicy in session

Avoids setting the policy in the registry
This commit is contained in:
Alessandro Pilotti 2013-01-31 17:01:52 +02:00
parent 3ad38a1945
commit 11e183212f
2 changed files with 2 additions and 9 deletions

View File

@ -215,13 +215,6 @@ class WindowsUtils(base.BaseOSUtils):
else:
return False
def check_powershell_exec_policy(self):
LOG.debug('Check Powershell execution policy')
args = ['powershell.exe',
'if ((Get-ExecutionPolicy).value__ -gt 1) '
'{ set-executionpolicy RemoteSigned}']
self.execute_process(args, False)
def get_network_adapters(self):
l = []
conn = wmi.WMI(moniker='//./root/cimv2')

View File

@ -46,8 +46,8 @@ class UserDataPlugin():
shell = False
elif re.search(r'^#ps1\s', user_data, re.I):
target_path += '.ps1'
args = ['powershell.exe', target_path]
osutils.check_powershell_exec_policy()
args = ['powershell.exe', '-ExecutionPolicy', 'RemoteSigned',
'-NonInteractive', target_path]
shell = False
else:
# Unsupported