PSADT.RunAsActiveUser Extension


Extension for PowerShell App Deployment Toolkit that executes processes or scriptblocks as the active user under SYSTEM context.


  • Executes processes, scripts or scriptblocks as the active user in SYSTEM context.
  • No need to change scripts, wraps original Execute-ProcessAsUser function but without UserName selection.
  • If executed under USER context, the function uses Execute-Process, no interpersonate needed.
  • No need to save scripts or to create files executed by scheduled tasks.
  • Executes scriptblocks on the fly if less than 32 KBytes (Windows 10), 8 KBytes (Windows 8.0 and under).
  • If size exceed the maximum, the temporary script is saved encrypted by 32 KB key and deleted during execution.
  • The execution of interpersonated processes returns the standard output of the invoked processes.
  • Able to Wait if neccesary.
  • Execution privilege works like original Execute-ProcessAsUser function, if active user is administrator, the process can be elevated.
  • Able to hide windows or console applications using parameters.
  • Fallbacks to original Execute-ProcessAsUser if any error occurs.
  • ContinueOnError and ExitScriptOnError support.

External Links

For more information related to the usage or installation, follow the external link.

With all the fun stuff we are having with the Execute-ProcessAsUser function in 3.9.x, using KelvinTegelaar/RunAsUser trick might be the way to go.

You are right! I’ve been using it for a while solving the issues found in my Toast Notification Extension and works like a charm.

This is the PSADT implementation of his work and a bit more.

For more information related to the usage or installation, follow the external link.

2023/04/14 - Updated to v1.0.1 :grinning:

  • Added ability to use Windows Powershell binaries when executed in Powershell ISE.