Determining 32/64 bit in Powershell

前端 未结 6 1948
梦谈多话
梦谈多话 2021-01-02 04:14

I am trying to create a couple lines of code that will pull from WMI if a machine is either 32/64 bit and then if it is 64 do this .... if it is 32bit do this...

Can

6条回答
  •  时光取名叫无心
    2021-01-02 05:06

    This is similar to a previous answer but will get a correct result regardless of 64-bit/64_bit/64bit/64bits format.

    if ((Get-WmiObject win32_operatingsystem | select osarchitecture).osarchitecture -like "64*")
    {
    #64bit code here
    Write "64-bit OS"
    }
    else
    {
    #32bit code here
    Write "32-bit OS"
    }
    

提交回复
热议问题