PowerShell / PowerShell/PowerShell
Allow `$PSCmdlet` methods in constrained language
Open
Nobody has claimed this yet.
Issue-Enhancement
Needs-Triage
WG-Cmdlets
WG-Reviewed
WG-Security
- Dominant language
- C#
- Stars
- 55.5k
- Forks
- 8.5k
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 88
Description
Summary of the new feature / enhancement
The following fails when using constrained language mode:
function Test-ShouldProcess {
[CmdletBinding(SupportsShouldProcess, ConfirmImpact = 'High')]
param()
if($PSCmdlet.ShouldProcess('something')) {
return $true
}
}
Error:
Cannot invoke method. Method invocation is supported only on core types in this language mode.
Other usages are also blocked, such as getting preference variables from caller scope within modules:
param (
$VerbosePreference = $PSCmdlet.GetVariableValue('VerbosePreference')
)
Proposed technical implementation details (optional)
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the ShouldProcess and GetVariableValue examples in constrained language mode, then trace the constrained-language method invocation handling. Define the permitted $PSCmdlet methods and verify that those calls work without weakening restrictions on other method invocations.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, powershell
- Domain
- cli, security
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100