Add -Current Parameter to Get-Process#27037
Add -Current Parameter to Get-Process#27037kilasuit wants to merge 5 commits intoPowerShell:masterfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new -Current switch to Get-Process to return the current PowerShell process without requiring $PID, intended to work in RestrictedLanguage scenarios (per #27028).
Changes:
- Introduces a new
MatchMode.ByCurrentand routes selection toProcess.GetCurrentProcess(). - Adds
-Current(andCurrentWithUserNameparameter set support) toGet-Process. - Adds a Pester test validating
Get-Process -Currentreturns a single process with the current PID.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
src/Microsoft.PowerShell.Commands.Management/commands/management/Process.cs |
Adds the new selection mode and -Current parameter set wiring for Get-Process. |
test/powershell/Modules/Microsoft.PowerShell.Management/Get-Process.Tests.ps1 |
Adds a new test asserting basic -Current behavior. |
You can also share your feedback on Copilot code review. Take the survey.
src/Microsoft.PowerShell.Commands.Management/commands/management/Process.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.PowerShell.Commands.Management/commands/management/Process.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.PowerShell.Commands.Management/commands/management/Process.cs
Outdated
Show resolved
Hide resolved
test/powershell/Modules/Microsoft.PowerShell.Management/Get-Process.Tests.ps1
Show resolved
Hide resolved
|
I will take another stab at what has been raised shortly |
597fa61 to
8d175dd
Compare
|
As mentioned in #27037, the name of the parameter |
|
@doctordns - the parameter There isn't any real need to expand this to CurrentPowerShellProcess and also as PowerShell can be embedded in a C# application calling this would then return that applications process as there is no real PowerShell process to return. So it doesn't actually make sense to call it as such. |
|
This pull request has been automatically marked as Review Needed because it has been there has not been any activity for 7 days. |
PR Summary
Return Current Process via Get-Command -Current to support Restricted Language Mode
Fixes #27028
PR Context
PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright header