Is using [intptr]::Size to check 32bits vs 64bits relevant?
In a deployment Powershell script, made by an editor, it use the following lines to determine if the server is 32 bits or 64 bits and download the appropriate package.
if ( [intptr]::Size -eq 8 ) {
$sourceUrl=-join($baseurl, "software/agent/Windows/x86_64/") }
else {
$sourceUrl=-join($baseurl, "software/agent/Windows/i386/") }
I have found one example of [intptr]::Size returning value 4 and the system is 64 bits on a Windows 2008 R2 server.
So should I consider the above method not right ? And which alternative can I use ?
Solution 1:
if ([Environment]::Is64BitOperatingSystem) {
$sourceUrl=-join($baseurl, "software/agent/Windows/x86_64/")
}
else {
$sourceUrl=-join($baseurl, "software/agent/Windows/i386/")
}
Source:
https://stackoverflow.com/questions/61396435/how-do-i-check-the-os-architecture32-or-64-bit-using-powershell