Fixes return code bug for powershell scripts
This commit is contained in:
parent
b4b9ba4fbb
commit
7b0c075ec1
@ -44,7 +44,7 @@ class ShellScriptPlugin(base.BaseUserDataPlugin):
|
||||
shell = False
|
||||
elif file_name.endswith(".ps1"):
|
||||
args = ['powershell.exe', '-ExecutionPolicy', 'RemoteSigned',
|
||||
'-NonInteractive', target_path]
|
||||
'-NonInteractive', '-File', target_path]
|
||||
shell = False
|
||||
else:
|
||||
# Unsupported
|
||||
|
@ -42,7 +42,7 @@ def execute_user_data_script(user_data):
|
||||
elif re.search(r'^#ps1\s', user_data, re.I):
|
||||
target_path += '.ps1'
|
||||
args = ['powershell.exe', '-ExecutionPolicy', 'RemoteSigned',
|
||||
'-NonInteractive', target_path]
|
||||
'-NonInteractive', '-File', target_path]
|
||||
shell = False
|
||||
elif re.search(r'^#ps1_sysnative\s', user_data, re.I):
|
||||
if os.path.isdir(os.path.expandvars('%windir%\\sysnative')):
|
||||
@ -51,7 +51,7 @@ def execute_user_data_script(user_data):
|
||||
'WindowsPowerShell\\v1.0\\'
|
||||
'powershell.exe'),
|
||||
'-ExecutionPolicy',
|
||||
'RemoteSigned', '-NonInteractive', target_path]
|
||||
'RemoteSigned', '-NonInteractive', '-File', target_path]
|
||||
shell = False
|
||||
else:
|
||||
# Unable to validate sysnative presence
|
||||
|
@ -74,7 +74,7 @@ class UserDataUtilsTest(unittest.TestCase):
|
||||
number_of_calls = 4
|
||||
extension = '.ps1'
|
||||
args = ['powershell.exe', '-ExecutionPolicy', 'RemoteSigned',
|
||||
'-NonInteractive', path+extension]
|
||||
'-NonInteractive', '-File', path+extension]
|
||||
shell = False
|
||||
else:
|
||||
side_effect = [None, None, None, None, match_instance]
|
||||
@ -86,7 +86,8 @@ class UserDataUtilsTest(unittest.TestCase):
|
||||
'WindowsPowerShell\\v1.0\\'
|
||||
'powershell.exe'),
|
||||
'-ExecutionPolicy',
|
||||
'RemoteSigned', '-NonInteractive', path+extension]
|
||||
'RemoteSigned', '-NonInteractive', '-File',
|
||||
path+extension]
|
||||
mock_path_isdir.return_value = True
|
||||
else:
|
||||
mock_path_isdir.return_value = False
|
||||
|
@ -63,7 +63,8 @@ class ShellScriptPluginTests(unittest.TestCase):
|
||||
elif filename.endswith(".ps1"):
|
||||
mock_osutils.execute_process.assert_called_with(
|
||||
['powershell.exe', '-ExecutionPolicy', 'RemoteSigned',
|
||||
'-NonInteractive', os.path.join(fake_dir_path, filename)],
|
||||
'-NonInteractive', '-File',
|
||||
os.path.join(fake_dir_path, filename)],
|
||||
False)
|
||||
self.assertFalse(response)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user