mirror of
https://github.com/KelvinTegelaar/RunAsUser.git
synced 2026-04-26 09:05:56 +03:00
[PR #12] [MERGED] Allow variables in $ScriptBlock #5
Labels
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/RunAsUser#5
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/KelvinTegelaar/RunAsUser/pull/12
Author: @cybermoloch
Created: 2/28/2021
Status: ✅ Merged
Merged: 3/5/2021
Merged by: @KelvinTegelaar
Base:
master← Head:cybermoloch-patch-1📝 Commits (1)
29e292aAllow variables in $ScriptBlock📊 Changes
1 file changed (+2 additions, -1 deletions)
View changed files
📝
Public/Invoke-AsCurrentUser.ps1(+2 -1)📄 Description
Uses $ExecutionContext.InvokeCommand.ExpandString to expand the $ScriptBlock to evaluate the variables from the calling script/function
Fixes KelvinTegelaar#7
There are security considerations when using this method. Since we are expanding the commands into a less privileged context, I think the risks are quite minimal to non-existent. An alternative would be to output and read back the commands as a temporary file but that has even more security implications (permissions of the files, race condition of the file being written vs read).
I've tested with a one line $ScriptBlock and three line $ScriptBlock.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.