Update samy.ps1

This commit is contained in:
2025-12-11 17:13:15 -05:00
parent 217e62c9a8
commit c0acdf38ed

View File

@@ -2930,31 +2930,35 @@ function Install-DattoRMM {
} }
if ($MyInvocation.InvocationName -eq '.') { if ($MyInvocation.InvocationName -eq '.') {
# dot-sourced, don't invoke return # dot-sourced, just define the function
} elseif ($PSCommandPath) { }
# script was saved and run directly
if ($PSBoundParameters.Count -gt 0) {
# Called like: & scriptblock -SilentInstall
Invoke-ScriptAutomationMonkey @PSBoundParameters Invoke-ScriptAutomationMonkey @PSBoundParameters
} else { }
# iwr | iex fallback elseif ($args.Count -gt 0) {
if ($args.Count -gt 0) { # Old-style args: script.ps1 -SilentInstall MyOtherParam value
# Convert -Param value -Switch into a hashtable for splatting
$namedArgs = @{} $namedArgs = @{}
for ($i = 0; $i -lt $args.Count; $i++) { for ($i = 0; $i -lt $args.Count; $i++) {
if ($args[$i] -is [string] -and $args[$i].StartsWith('-')) { if ($args[$i] -is [string] -and $args[$i].StartsWith('-')) {
$key = $args[$i].TrimStart('-') $key = $args[$i].TrimStart('-')
$next = $args[$i + 1] $next = if ($i + 1 -lt $args.Count) { $args[$i + 1] } else { $null }
if ($next -and ($next -notlike '-*')) { if ($next -and ($next -notlike '-*')) {
$namedArgs[$key] = $next $namedArgs[$key] = $next
$i++ # Skip next one, it's the value $i++
} else { } else {
$namedArgs[$key] = $true $namedArgs[$key] = $true
} }
} }
} }
Invoke-ScriptAutomationMonkey @namedArgs Invoke-ScriptAutomationMonkey @namedArgs
} else { }
else {
# No params: default to UI
Invoke-ScriptAutomationMonkey Invoke-ScriptAutomationMonkey
} }
}