Documentation Index
Fetch the complete documentation index at: https://tally.wharflab.com/llms.txt
Use this file to discover all available pages before exploring further.
powershell/PSUseUsingScopeModifierInNewRunspaces is a PSScriptAnalyzer diagnostic emitted by tally for PowerShell snippets embedded in Dockerfiles.
| Property | Value |
|---|---|
| Severity | Warning |
| Category | PSScriptAnalyzer |
| Auto-fix | No |
Description
If a scriptblock is intended to be run in a new runspace, variables inside it should use the$using: scope modifier, or be initialized within the scriptblock. This applies to:
Invoke-Command- Only with the ComputerName or Session parameter.Workflow { InlineScript {} }Foreach-Object- Only with the Parallel parameterStart-JobStart-ThreadJob- The
Scriptresource in DSC configurations, specifically for theGetScript,TestScriptandSetScriptproperties.
How to Fix
Within the ScriptBlock, instead of just using a variable from the parent scope, you have to add theusing: scope modifier to it.