[System.Net.ServicePointManager]::SecurityProtocol=[System.Net.SecurityProtocolType]'Tls12,Tls13'# or a bit shorter[Net.ServicePointManager]::SecurityProtocol=[Net.SecurityProtocolType]'Tls12,Tls13'
# short version one-liner:$u='https://cdn.jsdelivr.net/gh/aetonsi/misc/scripts/setup-gitbash-environment/main.ps1';irm $u|iex# extended version one-liner:$URL='https://cdn.jsdelivr.net/gh/aetonsi/misc/scripts/setup-gitbash-environment/main.ps1';Invoke-RestMethod$URL|Invoke-Expression
Run a remote (online) script, version 2
This script respects any #Requires directive and removes the need for any check about administrator privileges and whatnot.
# short version one-liner:$u='https://cdn.jsdelivr.net/gh/aetonsi/misc/scripts/setup-gitbash-environment/main.ps1';[Net.ServicePointManager]::SecurityProtocol=[Net.SecurityProtocolType]'Tls12,Tls13';Set-ExecutionPolicyb-sp-f;irm $u>($f="$([IO.Path]::GetTempPath())$([GUID]::NewGuid()).ps1");&$f;ri $f-f# extended version one-liner:$URL='https://cdn.jsdelivr.net/gh/aetonsi/misc/scripts/setup-gitbash-environment/main.ps1';[Net.ServicePointManager]::SecurityProtocol=[Net.SecurityProtocolType]'Tls12,Tls13';Set-ExecutionPolicyBypass-ScopeProcess-Force;Invoke-RestMethod$URL>($File="$([System.IO.Path]::GetTempPath())$([GUID]::NewGuid()).ps1");&$File;Remove-Item$File-Force# extended version line by line:$URL='https://cdn.jsdelivr.net/gh/aetonsi/misc/scripts/setup-gitbash-environment/main.ps1'[System.Net.ServicePointManager]::SecurityProtocol=[System.Net.SecurityProtocolType]'Tls12,Tls13'Set-ExecutionPolicyBypass-ScopeProcess-ForceInvoke-RestMethod$URL>($File="$([System.IO.Path]::GetTempPath())$([GUID]::NewGuid()).ps1")&$FileRemove-Item$File-Force
Run man about_Debuggers for information about debugging.
The following is a simple setup to trigger a debug session from within a script, like php's xdebug_break(), then allow for fiddling with the current powershell session. You can even access the session's variables current values. This session is more or less equivalent to running a powershell script with the -noexit argument, except that you can use this method in the middle of a script.
### debug-helper.ps1# define once, then SOURCE the script (see below)functiondebug_break(){}functiondebug_breakpoints_setup(){Get-PSBreakpoint|Remove-PSBreakpointSet-PSBreakpoint-Commanddebug_break>$null}
### some-script.ps1# call at the start of each script../debug-helper.ps1# dot-source the script (man about_Scripts); if importing a module instead, the debug session will not have access to the current scopedebug_breakpoints_setup# ... your script ...$xxx=Get-Random-Minimum0-Maximum1000Write-Output"`$xxx = $xxx"debug_break# this effectively starts the debug session here; you can test and access $xxx inside the sessionWrite-Output"after debug"# ...
You can then use hotkeys to control the debug session (run ? in a debug session for more info):
c: continues execution until the next breakpoint
s: steps into the next statement then stops
v: steps over the next statement, skipping invocations, then stops
k: displays current call stack
q: stops the script execution, like an Exit statement