Execution
5.1.0
Common execution helpers, self-elevation and stub-script wrapper for PowerShell.
Minimum PowerShell version
5.1
Installation Options
Owners
Copyright
(c) 2026 mtb.me. All rights reserved.
Package Details
Author(s)
- Manuel
Tags
Execution Self-Elevation Stub PowerShell Windows
Functions
Clear-TempDirectories ConvertTo-SplatHashtable Exit-AndWaitOnUI Format-SplatHashtable Get-QuotedPath Invoke-NativeCommand Invoke-StubScript Invoke-WhenFileChanged Remove-ItemSafe Restart-SelfElevated Set-PSScriptID
PSEditions
Dependencies
This module has no dependencies.
Release Notes
Execution v5.1.0+sha.3b1671c
## [v5.1.0] - 2026-05-06
### Added
- `Invoke-NativeCommand`: new `-Backend Auto|ScriptBlock|Process`
parameter to override the implicit backend selection. `Auto` (default)
keeps the v5.0 behaviour; `Process` and `ScriptBlock` force the
matching backend. Combining `-Backend ScriptBlock` with `-TimeoutSec`,
`-Encoding`, or `-NoWait` raises a terminating error rather than
silently ignoring the un-honoured switch.
- `Invoke-NativeCommand`: graceful-termination phase before hard-kill
on `-TimeoutSec`. New `-GracePeriodSec` parameter (default `5`,
range `0..3600`). The Process backend now sends SIGTERM (Unix) or
`Process.CloseMainWindow()` (Windows) when the timeout elapses, waits
up to `GracePeriodSec` for the process to exit cleanly, then falls
back to `Process.Kill()`. `-GracePeriodSec 0` restores v5.0
immediate-kill behaviour. Note: Windows console programs do not
respond to `CloseMainWindow`; for them the grace period is effectively
a no-op before the hard-kill fallback.
- `Invoke-NativeCommand`: new `-Stream` switch for live output. Each
captured stdout/stderr line is written to the host as it arrives
(stdout default color, stderr DarkYellow), in addition to the
existing `-PassThru` capture. Triggers the Process backend implicitly;
combining `-Stream` with `-Backend ScriptBlock` raises a terminating
error. Streaming pauses during the graceful-termination grace period
on `-TimeoutSec`; queued events are emitted in the post-exit drain.
### Fixed
- `Invoke-NativeCommand` Process backend: trailing stdout lines could
be reordered on Windows PowerShell 5.1 (B5 regression flake;
observed as `Stdout[-1] = 'line-999'` while `Stdout.Count = 1000`).
Root cause: the drain loop sorted PSEventManager events by
`TimeGenerated`, and two `OutputDataReceived` events fired
sub-millisecond apart can share a `TimeGenerated` value. PS 5.1's
`Sort-Object` is not stable (stable sort was added in PS 7), so
ties reorder consecutive lines. Sort by `EventIdentifier` instead --
it's monotonic per PSEventManager and reflects FIFO queue-insertion
order, giving a deterministic drain on every host. Also adds the
MSDN-recommended no-arg `Process.WaitForExit()` after the polling
loop on the non-timed-out branch as defense-in-depth (the timed-out
branch already called it via the kill sequence).
FileList
- Execution.nuspec
- Execution.psd1
- Execution.psm1
Version History
| Version | Downloads | Last updated |
|---|---|---|
| 5.3.2 | 20 | 5/11/2026 |
| 5.3.1 | 135 | 5/8/2026 |
| 5.3.0 | 103 | 5/7/2026 |
| 5.2.1 | 48 | 5/6/2026 |
| 5.2.0 | 85 | 5/6/2026 |
| 5.1.0 (current version) | 105 | 5/5/2026 |
| 5.0.0 | 7 | 5/5/2026 |
| 4.0.0 | 70 | 5/4/2026 |
| 3.0.1 | 497 | 4/16/2026 |
| 3.0.0 | 7 | 4/16/2026 |
| 2.1.1 | 1,663 | 12/29/2025 |
| 2.1.0 | 6 | 12/29/2025 |
| 2.0.2 | 75,833 | 4/28/2024 |
| 2.0.1 | 328 | 4/27/2024 |
| 2.0.0 | 11 | 4/26/2024 |
| 1.7.0 | 23,958 | 3/9/2020 |
| 1.6.2 | 447 | 2/5/2020 |
| 1.6.1 | 86 | 2/3/2020 |
| 1.6.0 | 42 | 2/3/2020 |
| 1.5.1 | 2,278 | 4/24/2019 |
| 1.5.0 | 201 | 4/1/2019 |
| 1.4.4 | 51 | 3/31/2019 |
| 1.4.3 | 43 | 3/31/2019 |
| 1.4.2 | 45 | 3/31/2019 |
| 1.4.1 | 43 | 3/30/2019 |
| 1.4.0 | 42 | 3/30/2019 |
| 1.3.0 | 43 | 3/30/2019 |
| 1.2.2 | 43 | 3/29/2019 |
| 1.2.1 | 42 | 3/29/2019 |
| 1.2.0 | 67 | 3/28/2019 |
| 1.1.0 | 48 | 3/27/2019 |
| 1.0.2 | 46 | 3/26/2019 |
| 1.0.1 | 104 | 3/17/2019 |
| 1.0.0 | 68 | 3/17/2019 |