-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Closed
Labels
Issue-BugIssue has been identified as a bug in the productIssue has been identified as a bug in the productResolution-No ActivityIssue has had no activity for 6 months or moreIssue has had no activity for 6 months or moreUp-for-GrabsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsUp-for-grabs issues are not high priorities, and may be opportunities for external contributors
Description
Prerequisites
- Write a descriptive title.
- Make sure you are able to repro it on the latest released version
- Search the existing issues.
- Refer to the FAQ.
- Refer to Differences between Windows PowerShell 5.1 and PowerShell.
Steps to reproduce
Note:
-
I'm assuming that the underlying .NET / Windows APIs don't support this combination; if so, an error should be reported.
-
Indeed the .NET APIs actively prevent the analogous combination (not sure about direct use of the WinAPI):
.Verb = "RunAs"
requires.UseShellExecute = true
, which in turn actively prevents modifying the environment via.Environment
or.EnvironmentVariables
(exception "The Process object must have the UseShellExecute property set to false in order to use environment variables.").
Start-Process -Verb RunAs cmd -Environment @{ foo='new' } '/c "echo [%foo%]" & pause' -Wait
Expected behavior
An error indicating that the specific parameter combination isn't supported.
Actual behavior
The process is launched, and the -Environment
argument is quietly ignored.
[%foo%]
Error details
No response
Environment data
PowerShell 7.4.0 on W11 22H2
Visuals
No response
Metadata
Metadata
Assignees
Labels
Issue-BugIssue has been identified as a bug in the productIssue has been identified as a bug in the productResolution-No ActivityIssue has had no activity for 6 months or moreIssue has had no activity for 6 months or moreUp-for-GrabsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsUp-for-grabs issues are not high priorities, and may be opportunities for external contributors