System.Environment allows to query information about the current environment (such as environment variables) and platform and manipulate these. PATH environment variable can be determined with PowerShell: $env:PATH="$env:PATH;p:\ath\to\foo\bar\baz"
$pathUser = [Environment]::GetEnvironmentVariable('PATH', 'user' )
$pathSystem = [Environment]::GetEnvironmentVariable('PATH', 'machine' )
$pathProcess = [Environment]::GetEnvironmentVariable('PATH', 'process' )
write-host "Paths of user:" ; write-host ( $pathUser -replace ';', "`n" )
write-host "Paths of system:" ; write-host ( $pathSystem -replace ';', "`n" )
write-host "Paths of process:" ; write-host ( $pathProcess -replace ';', "`n" )
$folder is a value of a member of the System.Environment+SpecialFolder enum, the text value for this path is returned by GetFolderPath($folder), as is demonstrated with the following PowerShell snippet: PS C:\> [System.Environment]::GetFolderPath([System.Environment+SpecialFolder]::UserProfile) C:\Users\Rene
MachineName evaluates to the NetBIOS name of the local computer. OSVersion returns an System.OperatingSystem object. [environment]::setEnvironmentVariable('USER_VAR' , 'foo', 'user' )
[environment]::setEnvironmentVariable('GLOBAL_VAR', 'bar', 'machine')
[environment]::setEnvironmentVariable('PROC_VAR' , 'baz', 'process')
Environment.SystemDirectory is the name of the fully qualified system directory, for example C:\Windows\System32. Version returns a System.Version object that corresponds to the version of the Common Language Runtime. [System.Runtime.InteropServices.RuntimeInformation]::FrameworkDescription static properties Is64BitOperatingSystem and Is64BitProcess. GetEnvironmentVariables() is here.