Execution

5.4.0

Common execution helpers, self-elevation and stub-script wrapper for PowerShell.

Minimum PowerShell version

5.1

Installation Options

Copy and Paste the following command to install this package using PowerShellGet More Info

Install-Module -Name Execution

Copy and Paste the following command to install this package using Microsoft.PowerShell.PSResourceGet More Info

Install-PSResource -Name Execution

You can deploy this package directly to Azure Automation. Note that deploying packages with dependencies will deploy all the dependencies to Azure Automation. Learn More

Manually download the .nupkg file to your system's default download location. Note that the file won't be unpacked, and won't include any dependencies. Learn More

Owners

Copyright

(c) 2026 mtb.me. All rights reserved.

Package Details

Author(s)

  • Manuel

Tags

Execution Self-Elevation Stub PowerShell Windows Environment EnvVar PATH PSModulePath

Functions

Add-ToMultiValueEnvVar Clear-TempDirectories ConvertTo-SplatHashtable Exit-AndWaitOnUI Format-SplatHashtable Get-QuotedPath Invoke-NativeCommand Invoke-StubScript Invoke-WhenFileChanged Remove-EnvVar Remove-FromMultiValueEnvVar Remove-ItemSafe Remove-NativeProgressNoise Restart-SelfElevated Set-EnvVar Set-PSScriptID

PSEditions

Desktop Core

Dependencies

This module has no dependencies.

Release Notes

Execution v5.4.0+sha.1b54cba

## [v5.4.0] - 2026-05-18

### Added

- `Set-EnvVar` / `Remove-EnvVar`: persist or delete a User- or
 Machine-scope environment variable via
 `[System.Environment]::SetEnvironmentVariable`, which writes to the
 registry (`HKCU\Environment` for User, the corresponding
 `HKLM\...\Session Manager\Environment` key for Machine) and broadcasts
 `WM_SETTINGCHANGE`. Default scope is User; Machine requires elevation
 and the cmdlets refuse with a clear error otherwise.
 `SupportsShouldProcess` (`ConfirmImpact = 'Medium'`) with per-call
 gate. `-UpdateCurrentProcess` additionally mirrors the change into
 the current process environment so the change is visible without
 spawning a new shell.
- `Add-ToMultiValueEnvVar` / `Remove-FromMultiValueEnvVar`: order-
 preserving operations on delimited variables (`PATH`, `PSModulePath`,
 any `';'`-delimited list). Deduplicates while keeping the first
 occurrence; `-PathSemantics` makes the comparison case-insensitive
 and trailing-slash-tolerant (the right behaviour for `PATH` /
 `PSModulePath`). `Add-...` supports `-Prepend`; `Remove-...` accepts
 either `-Value` or a `-Where` scriptblock predicate via mutually
 exclusive parameter sets.
- `src/Execution/Templates/`: stub-script templates for env-var
 management (`add-envvar`, `remove-envvar`, `_add-this-dir-to-...`,
 `_remove-this-dir-from-...`, each as a `.cmd.template` +
 `.ps1.template` pair, in User / Machine / Interactive variants).
 Ship inside the built module under
 `(Get-Module -ListAvailable Execution).ModuleBase\Templates\`. The
 `.cmd` is a generic launcher that auto-selects `pwsh-preview`,
 `pwsh`, or `powershell`; the `.ps1` payload uses
 `Invoke-StubScript` for the boilerplate (caller tracking,
 self-elevation, WhatIf/Confirm forwarding, UI-aware exit) and
 `Set-EnvVar` / `Add-ToMultiValueEnvVar` for the actual env-var
 work - all from this module.
- `build.ps1`: copy `src/Execution/Templates/` into the built artifact
 directory after `Build-Module`. ModuleBuilder's `PublicFilter` only
 picks up `.ps1` files under `Public\`, so `.template` and `.md`
 assets need a manual copy step to ship inside the PSGallery package.

FileList

  • Execution.nuspec
  • Execution.psd1
  • Execution.psm1
  • Templates\README.md
  • Templates\_add-this-dir-to-VARNAME-envvar.cmd.template
  • Templates\_add-this-dir-to-VARNAME-envvar.machine.cmd.template
  • Templates\_add-this-dir-to-VARNAME-envvar.machine.ps1.template
  • Templates\_add-this-dir-to-VARNAME-envvar.ps1.template
  • Templates\_remove-this-dir-from-VARNAME-envvar.cmd.template
  • Templates\_remove-this-dir-from-VARNAME-envvar.machine.cmd.template
  • Templates\_remove-this-dir-from-VARNAME-envvar.machine.ps1.template
  • Templates\_remove-this-dir-from-VARNAME-envvar.ps1.template
  • Templates\add-envvar.cmd.template
  • Templates\add-envvar.interactive.cmd.template
  • Templates\add-envvar.interactive.machine.cmd.template
  • Templates\add-envvar.interactive.machine.ps1.template
  • Templates\add-envvar.interactive.ps1.template
  • Templates\add-envvar.machine.cmd.template
  • Templates\add-envvar.machine.ps1.template
  • Templates\add-envvar.ps1.template
  • Templates\remove-envvar.cmd.template
  • Templates\remove-envvar.machine.cmd.template
  • Templates\remove-envvar.machine.ps1.template
  • Templates\remove-envvar.ps1.template

Version History

Version Downloads Last updated
5.4.0 (current version) 0 5/18/2026
5.3.4 12 5/15/2026
5.3.3 21 5/15/2026
5.3.2 184 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 110 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
Show more