Skip to content

Commit

Permalink
test theory
Browse files Browse the repository at this point in the history
  • Loading branch information
donoghuc committed Apr 3, 2024
1 parent 19ee965 commit 9634fdd
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions lib/bolt/shell/powershell/snippets.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,21 +55,25 @@ def run_script(arguments, script_path)
}
#{build_arg_list}
switch -regex ( Get-ExecutionPolicy )
try
{
'^AllSigned'
switch -regex ( Get-ExecutionPolicy )
{
if ((Get-AuthenticodeSignature -File "#{script_path}").Status -ne 'Valid') {
$Host.UI.WriteErrorLine("Error: Target host Powershell ExecutionPolicy is set to ${_} and script '#{script_path}' does not contain a valid signature.")
'^AllSigned'
{
if ((Get-AuthenticodeSignature -File "#{script_path}").Status -ne 'Valid') {
$Host.UI.WriteErrorLine("Error: Target host Powershell ExecutionPolicy is set to ${_} and script '#{script_path}' does not contain a valid signature.")
exit 1;
}
}
'^Restricted'
{
$Host.UI.WriteErrorLine("Error: Target host Powershell ExecutionPolicy is set to ${_} which denies running any scripts on the target.")
exit 1;
}
}
'^Restricted'
{
$Host.UI.WriteErrorLine("Error: Target host Powershell ExecutionPolicy is set to ${_} which denies running any scripts on the target.")
exit 1;
}
}
catch {}
if([string]::IsNullOrEmpty($invokeArgs.ScriptBlock)){
$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");
Expand Down

0 comments on commit 9634fdd

Please sign in to comment.