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 ?

  • 3
    That (probably) checks whether the powershell interpreter you're using is 32bit or 64bit. Are you running 32bit powershell on the 64bit system? – Mat Nov 27 '20 at 16:55
  • @Mat, yes it's exactly that, on a 64 bits OS the result will depend of the powershell interpreter ! So the editor method is not reliable at all. – Whysmerhill Nov 29 '20 at 10:55
if ([Environment]::Is64BitOperatingSystem) { 
  $sourceUrl=-join($baseurl, "software/agent/Windows/x86_64/")  
else {
  $sourceUrl=-join($baseurl, "software/agent/Windows/i386/")  



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.