diff --git a/StackMonkey.ps1 b/StackMonkey.ps1 index a77b7d9..6229cf2 100644 --- a/StackMonkey.ps1 +++ b/StackMonkey.ps1 @@ -136,6 +136,27 @@ & ([ScriptBlock]::Create((iwr 'sm.svstools.com').Content)) -Cleanup #> +#region Safely bypass Restricted Execution Policy +# ─── Safely bypass Restricted Execution Policy ─── +if ($ExecutionContext.SessionState.LanguageMode -ne 'FullLanguage' -or + (Get-ExecutionPolicy) -eq 'Restricted') { + + Write-Host "[Info] Relaunching with ExecutionPolicy Bypass..." -ForegroundColor Yellow + + if ($PSCommandPath) { + powershell.exe -NoProfile -ExecutionPolicy Bypass -File "`"$PSCommandPath`"" + } else { + powershell.exe -NoProfile -ExecutionPolicy Bypass -Command "& { iwr 'https://sm.svstools.com' -UseBasicParsing | iex }" + } + + exit +} + +# ─── TLS and silent install defaults ─── +[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 +$ProgressPreference = 'SilentlyContinue' +$ConfirmPreference = 'None' +#endregion Safely bypass Restricted Execution Policy function Invoke-ScriptMonkey { @@ -1658,6 +1679,7 @@ function Install-DattoRMM { } #endregion EntryPoint: Define Invoke-ScriptMonkey + #region — guarantee NuGet provider is present without prompting # ─── NuGet + PSGallery bootstrap (safe & silent) ───