在 Powershell 中确定 32/64 位 [英] Determining 32/64 bit in Powershell

查看:75
本文介绍了在 Powershell 中确定 32/64 位的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果机器是 32/64 位,我正在尝试创建几行代码,这些代码将从 WMI 中提取,然后如果它是 64 位,请执行此操作....如果它是 32 位执行此操作...

有人可以帮忙吗?

解决方案

Environment 中有两个布尔静态方法可以检查和比较,一个查看 PowerShell 进程,一个查看底层操作系统.

if ([环境]::Is64BitProcess -ne [环境]::Is64BitOperatingSystem){PowerShell 进程与操作系统不匹配"}

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 anyone help?

解决方案

There's two boolean static methods in the Environment you can inspect and compare, one looks at the PowerShell process, one looks at the underlying OS.

if ([Environment]::Is64BitProcess -ne [Environment]::Is64BitOperatingSystem)
{
"PowerShell process does not match the OS"
}

这篇关于在 Powershell 中确定 32/64 位的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆