PowerShell: The scope in the different script blocks of «Switch» are different too
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
$Private:P = "PP"
$Local:L = "LL"
$Global:G = "GG"
"`$P=$P `$L=$L `$G=$G"
Switch ($AnyValue) {
{"`$P=$P `$L=$L `$G=$G" | Out-Host; $True} {"`$P=$P `$L=$L `$G=$G"}
}
Expected behavior
$P=PP $L=LL $G=GG
$P=PP $L=LL $G=GG
$P=PP $L=LL $G=GG
Actual behavior
$P=PP $L=LL $G=GG
$P= $L=LL $G=GG
$P=PP $L=LL $G=GG
Error details
No response
Environment data
PSVersion 7.3.1
PSEdition Core
GitCommitId 7.3.1
OS Microsoft Windows 10.0.19045
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Visuals
No response
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 22 (8 by maintainers)
Thank you for your moral support.