You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
(maint) Do not error when Execution Policy cannot be determined
We attempt to compute Execution Policy in order to provide a nice error message for some cases. We are seeing failures in some cases to compute this value. In the case the execution policy cannot be determined we still want to be able to attempt to run the action. This commit handles errors when execution policy cannot be determined.
if ((Get-AuthenticodeSignature -File "#{script_path}").Status -ne 'Valid') {
63
-
$Host.UI.WriteErrorLine("Error: Target host Powershell ExecutionPolicy is set to ${_} and script '#{script_path}' does not contain a valid signature.")
62
+
'^AllSigned'
63
+
{
64
+
if ((Get-AuthenticodeSignature -File "#{script_path}").Status -ne 'Valid') {
65
+
$Host.UI.WriteErrorLine("Error: Target host Powershell ExecutionPolicy is set to ${_} and script '#{script_path}' does not contain a valid signature.")
66
+
exit 1;
67
+
}
68
+
}
69
+
'^Restricted'
70
+
{
71
+
$Host.UI.WriteErrorLine("Error: Target host Powershell ExecutionPolicy is set to ${_} which denies running any scripts on the target.")
64
72
exit 1;
65
73
}
66
74
}
67
-
'^Restricted'
68
-
{
69
-
$Host.UI.WriteErrorLine("Error: Target host Powershell ExecutionPolicy is set to ${_} which denies running any scripts on the target.")
$Host.UI.WriteErrorLine("Error: Failed to obtain scriptblock from '#{script_path}'. Running scripts might be disabled on this system. For more information, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170");
0 commit comments