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