You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ScriptBlock.InvokeWithContext mutates variable lists passed as arguments #12928
If passed a variable that is (for lack of established term afaik) intrinsic to the scope, the variable entry will be removed from the list passed in variablesToDefine. This includes vars such as $this, $input, $_ and $PSItem.
Patrick Meinecke (@SeeminglyScience) Correct and by design. Intrinsic variables already have a set of rules for when and how they are bound. This API was not intended to change those rules. What it does is allow you to provide ambient context to the script block when it executes. This is used by DSC internally to define the set of resources (functions) available inside a configuration (function). For example, if you want to make a function available to a scriptblock without setting it in the current scope and thus making it visible to everything you do, you can use this API. It's particularly useful in modules where you can't use dynamic scoping to provision an execution environment. Does that make sense?
Patrick Meinecke (@SeeminglyScience) Correct and by design. Intrinsic variables already have a set of rules for when and how they are bound. This API was not intended to change those rules. What it does is allow you to provide ambient context to the script block when it executes. This is used by DSC internally to define the set of resources (functions) available inside a configuration (function). For example, if you want to make a function available to a scriptblock without setting it in the current scope and thus making it visible to everything you do, you can use this API. It's particularly useful in modules where you can't use dynamic scoping to provision an execution environment. Does that make sense?
Bruce Payette (@bpayette) It works, you can set intrinsic variables with this API. The API iterates the List<PSVariable> looking for intrinsic variables and removes them to be handled separately (through InvokeWithPipe parameters).
This issue is just about the List<> argument getting mutated because of internal logic. I would have expected a copy of the list to have been made if changes were needed before it passed the list to InvokeWithPipe.
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.
microsoft-github-policy-service commented on Nov 16, 2023
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.
microsoft-github-policy-service commented on Nov 16, 2023
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.
Activity
bpayette commentedon Jun 10, 2020
Patrick Meinecke (@SeeminglyScience) Correct and by design. Intrinsic variables already have a set of rules for when and how they are bound. This API was not intended to change those rules. What it does is allow you to provide ambient context to the script block when it executes. This is used by DSC internally to define the set of resources (functions) available inside a configuration (function). For example, if you want to make a function available to a scriptblock without setting it in the current scope and thus making it visible to everything you do, you can use this API. It's particularly useful in modules where you can't use dynamic scoping to provision an execution environment. Does that make sense?
bpayette commentedon Jun 10, 2020
Patrick Meinecke (@SeeminglyScience) Correct and by design. Intrinsic variables already have a set of rules for when and how they are bound. This API was not intended to change those rules. What it does is allow you to provide ambient context to the script block when it executes. This is used by DSC internally to define the set of resources (functions) available inside a configuration (function). For example, if you want to make a function available to a scriptblock without setting it in the current scope and thus making it visible to everything you do, you can use this API. It's particularly useful in modules where you can't use dynamic scoping to provision an execution environment. Does that make sense?
SeeminglyScience commentedon Jun 10, 2020
Bruce Payette (@bpayette) It works, you can set intrinsic variables with this API. The API iterates the
List<PSVariable>looking for intrinsic variables and removes them to be handled separately (throughInvokeWithPipeparameters).This issue is just about the
List<>argument getting mutated because of internal logic. I would have expected a copy of the list to have been made if changes were needed before it passed the list toInvokeWithPipe.microsoft-github-policy-service commentedon Nov 16, 2023
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.
microsoft-github-policy-service commentedon Nov 16, 2023
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.
microsoft-github-policy-service commentedon Nov 16, 2023
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.
microsoft-github-policy-service commentedon Nov 23, 2023
This issue has been marked as "No Activity" as there has been no activity for 6 months. It has been closed for housekeeping purposes.