I am trying to be consistent in my code, using either $env: or [Environment], but not a mix. However, I am seeing some inconsistencies in what seems to be implemented.
So [Environment]::UserName and $env:userName both work fine. $env:computerName works, but [Environment]::COMPUTERNAME doesn't. Oddly [Environment]::MachineName does, despite the fact that [Environment]::GetEnvironmentVariables() says [Environment]::COMPUTERNAME is present, not [Environment]::MachineName. Also, [Environment]::GetEnvironmentVariables() says [Environment]::USERPROFILE should work, but it actually returns nothing.
When I look at the Microsoft doc here about properties of the [Environment] type I do see MachineName, along with UserName, and no mention of UserProfile. So, obviously that IS the right resource. But that begs the question, why does [Environment]::GetEnvironmentVariables() return such inconsistent information?
