PS: Behavior of Environment Variable Prioritization
Priority handling when there are conflicting and/or same variables at both Machine and User level: PS C:> $a = [Environment]::GetEnvironmentVariable("Temp","Machine") PS C:> echo $a C:WindowsTEMP PS C:> $a = [Environment]::GetEnvironmentVariable("Temp","User") PS C:> echo $a C:UsersgovardhanAppDataLocalTemp PS C:> $a = [Environment]::GetEnvironmentVariable("Temp") PS C:> echo $a C:UsersGOVARD~1AppDataLocalTemp PS C:> In case of a conflict, Windows and thus PS refers to User level variable under a user session. The weird behavior is sometimes, you environment variables aren’t read as either type “User” or “Machine” but can be read without any type specification. PS C:> $a = [Environment]::GetEnvironmentVariable("appdata","User") PS C:> echo $a PS […]
Read more