Fix to set Powershell's ExecutionPolicy in session
Avoids setting the policy in the registry
This commit is contained in:
parent
3ad38a1945
commit
11e183212f
@ -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')
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user