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:
|
else:
|
||||||
return False
|
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):
|
def get_network_adapters(self):
|
||||||
l = []
|
l = []
|
||||||
conn = wmi.WMI(moniker='//./root/cimv2')
|
conn = wmi.WMI(moniker='//./root/cimv2')
|
||||||
|
@ -46,8 +46,8 @@ class UserDataPlugin():
|
|||||||
shell = False
|
shell = False
|
||||||
elif re.search(r'^#ps1\s', user_data, re.I):
|
elif re.search(r'^#ps1\s', user_data, re.I):
|
||||||
target_path += '.ps1'
|
target_path += '.ps1'
|
||||||
args = ['powershell.exe', target_path]
|
args = ['powershell.exe', '-ExecutionPolicy', 'RemoteSigned',
|
||||||
osutils.check_powershell_exec_policy()
|
'-NonInteractive', target_path]
|
||||||
shell = False
|
shell = False
|
||||||
else:
|
else:
|
||||||
# Unsupported
|
# Unsupported
|
||||||
|
Loading…
x
Reference in New Issue
Block a user