Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Check if OS is 32bit or 64bit

$
0
0

Hello All,

I hoping that someone might be able to explain and help point me into the right direction.  I'm trying to check for which version a machine OS as well check for a certain folder and for some reason I'm having problems getting my script to work.  Below is what I'm using. What I except to see when running the script is when the WmiObject -contains 32 (which returns true) it should excute the script block {test-path $32OS}, but it doesn't it goes to check WmiObject -contains 64 then excute script block {test-path $64OS}.  Any help would be great.  Thank you!

btw the reason for using -contains switch is because we have systems that either has 2 or 4 cores which returns the integers instead of the boolean "true or false"

$PC = Get-Content c:\ComputerList.txt
Function check-file {
Process {
$32OS = "\\$_\c$\somedirectory"
$64OS = "\\$_\c$\somedirectory"
if (((Get-WmiObject win32_processor).addresswidth) -contains 32)
	 {
	 test-path $32OS 
          }
       elseif (((Get-WmiObject win32_processor).addresswidth) -contains 64)
     	 {
          test-path $64OS
          }
 }
}



Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>