This behavior is surprising to me. I'm not sure if it is as intended, as neither the documentation for ScopedItemOptions nor about_Scopes seem to contemplate the behavior of AllScope variables in the context of multiple SessionStates.
Steps to reproduce
$m = New-Module {}
Set-Variable v -Value 'v.1' -Option AllScope
& $m { $v }
& $m { $v = 'v.2'; $v }
$v
& {
$v = 'v.3'
}
$v
& $m { $v }
Expected behavior
I expected that
either there really is only one $v and the output is
or, there are two $v that are really unrelated and the output is
Actual behavior
The actual behavior seems to be consistent with two $v that are sort-of related.
Environment data
> $PSVersionTable
Name Value
---- -----
PSVersion 6.0.0
PSEdition Core
GitCommitId v6.0.0
OS Microsoft Windows 6.3.9600
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
This behavior is surprising to me. I'm not sure if it is as intended, as neither the documentation for ScopedItemOptions nor about_Scopes seem to contemplate the behavior of
AllScopevariables in the context of multiple SessionStates.Steps to reproduce
Expected behavior
I expected that
either there really is only one
$vand the output isor, there are two
$vthat are really unrelated and the output isActual behavior
The actual behavior seems to be consistent with two
$vthat are sort-of related.Environment data