Update samy.ps1
This commit is contained in:
27
samy.ps1
27
samy.ps1
@@ -158,24 +158,43 @@ $Script:SamyBranch = 'beta' # or 'main'
|
|||||||
#>
|
#>
|
||||||
#region Safely bypass Restricted Execution Policy
|
#region Safely bypass Restricted Execution Policy
|
||||||
# ─── Safely bypass Restricted Execution Policy ───
|
# ─── Safely bypass Restricted Execution Policy ───
|
||||||
|
#region Safely bypass Restricted Execution Policy
|
||||||
|
# Safely bypass Restricted Execution Policy
|
||||||
if ($ExecutionContext.SessionState.LanguageMode -ne 'FullLanguage' -or
|
if ($ExecutionContext.SessionState.LanguageMode -ne 'FullLanguage' -or
|
||||||
(Get-ExecutionPolicy) -eq 'Restricted') {
|
(Get-ExecutionPolicy) -eq 'Restricted') {
|
||||||
|
|
||||||
Write-Host "[Info] Relaunching with ExecutionPolicy Bypass..." -ForegroundColor Yellow
|
Write-Host "[Info] Relaunching with ExecutionPolicy Bypass..." -ForegroundColor Yellow
|
||||||
|
|
||||||
if ($PSCommandPath) {
|
# Rebuild the original argument list as a string to pass through
|
||||||
powershell.exe -NoProfile -ExecutionPolicy Bypass -File "`"$PSCommandPath`""
|
$argList = @()
|
||||||
|
foreach ($a in $args) {
|
||||||
|
if ($a -is [string]) {
|
||||||
|
# Quote and escape any existing quotes
|
||||||
|
$escaped = $a.Replace('"','`"')
|
||||||
|
$argList += "`"$escaped`""
|
||||||
} else {
|
} else {
|
||||||
powershell.exe -NoProfile -ExecutionPolicy Bypass -Command "& { iwr 'https://samy.svstools.com' -UseBasicParsing | iex }"
|
$argList += $a.ToString()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$argString = $argList -join ' '
|
||||||
|
|
||||||
|
if ($PSCommandPath) {
|
||||||
|
# Script saved on disk: re-run same file with same args
|
||||||
|
powershell.exe -NoProfile -ExecutionPolicy Bypass -File "`"$PSCommandPath`"" $argString
|
||||||
|
} else {
|
||||||
|
# iwr | iex scenario: re-download SAMY and apply same args
|
||||||
|
powershell.exe -NoProfile -ExecutionPolicy Bypass -Command "& { iwr 'https://samy.svstools.ca' -UseBasicParsing | iex } $argString"
|
||||||
}
|
}
|
||||||
|
|
||||||
exit
|
exit
|
||||||
}
|
}
|
||||||
|
|
||||||
# ─── TLS and silent install defaults ───
|
# TLS and silent install defaults
|
||||||
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
|
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
|
||||||
$ProgressPreference = 'SilentlyContinue'
|
$ProgressPreference = 'SilentlyContinue'
|
||||||
$ConfirmPreference = 'None'
|
$ConfirmPreference = 'None'
|
||||||
|
#endregion Safely bypass Restricted Execution Policy
|
||||||
|
|
||||||
#endregion Safely bypass Restricted Execution Policy
|
#endregion Safely bypass Restricted Execution Policy
|
||||||
|
|
||||||
function Invoke-ScriptAutomationMonkey {
|
function Invoke-ScriptAutomationMonkey {
|
||||||
|
|||||||
Reference in New Issue
Block a user