Invoke-AsCurrentUser_WithArgs
1.1.0
Execute PowerShell scriptblocks in the context of the currently logged-in user from a SYSTEM context. Ideal for Intune deployments, SCCM task sequences, and scheduled tasks. Supports argument passing, transcript capture, stream capture, and configurable timeouts.
Minimum PowerShell version
5.1
Installation Options
Owners
Copyright
(c) 2025-2026. All rights reserved.
Package Details
Author(s)
- Harze2k
Tags
RunAsUser Intune SCCM SYSTEM UserContext Deployment Windows
Functions
Invoke-AsCurrentUser_WithArgs Serialize-Object Deserialize-Object Get-RunAsUserCSharpSource
PSEditions
Dependencies
This module has no dependencies.
Release Notes
## Version 1.1.0
- Replaced all throw statements with Write-Error and graceful return patterns to prevent script termination
- Improved error handling: functions now return $null on failure instead of throwing
- Added consistent ExecutionSuccess property to all result output paths
- Stream capture results (StdOut, StdErr, Warnings, Verbose) now always present when -CaptureStreams is used (empty string instead of missing)
- Improved parameter validation error messages with Write-Error instead of silent Write-Warning
- Updated function descriptions and synopsis for clarity
- Fixed WorkingDirectory parameter validation to handle empty strings properly
- Added error result output on Add-Type compilation failure
- Improved timeout handling to return structured error objects instead of throwing
- Backup log file naming now uses timestamp instead of random number for easier troubleshooting
## Version 1.0.0
- Initial release
- Execute scriptblocks as currently logged-in user
- Pass arguments/variables to scriptblocks
- Capture transcript and execution results
- Support for PowerShell 5.1 and 7+
- Configurable timeout handling
- Optional stream capture (stdout/stderr)
FileList
- Invoke-AsCurrentUser_WithArgs.nuspec
- Invoke-AsCurrentUser_WithArgs.psd1
- Invoke-AsCurrentUser_WithArgs.psm1
- LICENSE
- README.md
Version History
| Version | Downloads | Last updated |
|---|---|---|
| 1.1.0 (current version) | 77 | 3/13/2026 |
| 1.0.0 | 808 | 12/1/2025 |