Detect ARM64 host in PowerShell on Windows, Linux and macOS.
Since I can't find it anywhere else on the web, here's how you detect ARM64 xplat.
1# Determine OS and Architecture
2$osPlatform = [System.Runtime.InteropServices.RuntimeInformation]::OSDescription
3$architecture = [System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture
4
5# Adjust the platform and architecture for the API call
6$platform = switch -Wildcard ($osPlatform) {
7 "*Windows*" { "win32" }
8 "*Linux*" { "linux" }
9 "*Darwin*" { "darwin" } # MacOS is identified as Darwin
10 Default { "unknown" }
11}
12$arch = switch ($architecture) {
13 "X64" { "x64" }
14 "X86" { "x86" }
15 "Arm" { "arm" }
16 "Arm64" { "arm64" }
17 Default { "unknown" }
18}