Update Download-WinRMConfigScript.ps1 to version 1.2.0, modifying exit behavior to prevent closing the PowerShell window when run via "irm | iex".
This commit is contained in:
@@ -36,11 +36,13 @@
|
|||||||
.NOTES
|
.NOTES
|
||||||
Author: Petr Štěpán
|
Author: Petr Štěpán
|
||||||
Created: 2026-07-21
|
Created: 2026-07-21
|
||||||
Version: 1.1.0
|
Version: 1.2.0
|
||||||
Changelog:
|
Changelog:
|
||||||
1.0.0 - Initial version
|
1.0.0 - Initial version
|
||||||
1.1.0 - Added $env:ZabbixProxyIPAddress fallback so a plain "irm | iex"
|
1.1.0 - Added $env:ZabbixProxyIPAddress fallback so a plain "irm | iex"
|
||||||
one-liner can supply the IP address without "& { ... } -Param" wrapping
|
one-liner can supply the IP address without "& { ... } -Param" wrapping
|
||||||
|
1.2.0 - Only call exit when running as a real .ps1 file, not when run via
|
||||||
|
"irm | iex" - exit would otherwise close the caller's PowerShell window
|
||||||
#>
|
#>
|
||||||
|
|
||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
@@ -181,7 +183,16 @@ try {
|
|||||||
}
|
}
|
||||||
catch {
|
catch {
|
||||||
Write-Error "Script failed: $_"
|
Write-Error "Script failed: $_"
|
||||||
|
# $MyInvocation.MyCommand.Path is only set when this runs as an actual .ps1 file.
|
||||||
|
# When run via "irm <url> | iex" there is no backing file - the code executes in
|
||||||
|
# the caller's own session, so calling exit here would close their whole
|
||||||
|
# PowerShell window instead of just ending this script.
|
||||||
|
if ($MyInvocation.MyCommand.Path) {
|
||||||
exit 1
|
exit 1
|
||||||
|
}
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
exit 0
|
if ($MyInvocation.MyCommand.Path) {
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user