Any reason why the $env:PROCESSOR_ARCHITECTURE was left out? I think is useful.
This is missing in both Linux and MacOS PSCore6.
Execute the following command in either Linux or MacOS PSCore and the variable is missing.
dir env:
This variable $env:PROCESSOR_ARCHITECTURE to exist
No provided in non-Windows OS.
CentOS:
PS /home/maxt> cat /etc/os-release
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"
CENTOS_MANTISBT_PROJECT="CentOS-7"
CENTOS_MANTISBT_PROJECT_VERSION="7"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="7"
MacOS:
Maximos-Mac:~ maxt$ sw_vers
ProductName: Mac OS X
ProductVersion: 10.13.4
BuildVersion: 17E199
#CentOS
PS /home/maxt> $PSVersionTable
Name Value
---- -----
PSVersion 6.1.0-preview.2
PSEdition Core
GitCommitId v6.1.0-preview.2
OS Linux 3.10.0-693.21.1.el7.x86_64 #1 SMP Wed Mar 7 19:03:37 UTC 2018
Platform Unix
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
#MacOS
PS /Users/maxt> $PSVersionTable
Name Value
---- -----
PSVersion 6.1.0-preview.2
PSEdition Core
GitCommitId v6.1.0-preview.2
OS Darwin 17.5.0 Darwin Kernel Version 17.5.0: Mon Mar 5 22:24:32 PST 2018; root:xnu-45...
Platform Unix
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
I believe that, being an environment variable, PowerShell does not control the existence of that setting. It's the host OS that sets PROCESSOR_ARCHITECTURE
in the environment, and there's been a general preference for PowerShell not to set new environment variables (especially since this potentially breaks things).
To be clear, go into cmd.exe
on Windows and type echo %PROCESSOR_ARCHITECTURE%
and you should see the value. Go into bash
on UNIX and type echo $PROCESSOR_ARCHITECTURE
and you won't get anything by default. PowerShell aims to do the same on each respective platform.
Just for the sake of completeness, on UNIX you should be able to use uname -m
(I think $PSVersionTable
uses this for OS
). I think there might have been some discussion about PowerShell having an internal variable to track processor architecture too.
Thanks everyone!!
:)
Most helpful comment
I believe that, being an environment variable, PowerShell does not control the existence of that setting. It's the host OS that sets
PROCESSOR_ARCHITECTURE
in the environment, and there's been a general preference for PowerShell not to set new environment variables (especially since this potentially breaks things).To be clear, go into
cmd.exe
on Windows and typeecho %PROCESSOR_ARCHITECTURE%
and you should see the value. Go intobash
on UNIX and typeecho $PROCESSOR_ARCHITECTURE
and you won't get anything by default. PowerShell aims to do the same on each respective platform.