gpt4 book ai didi

powershell - 检查处理器体系结构并继续执行if语句

转载 作者:行者123 更新时间:2023-12-03 01:17:39 26 4
gpt4 key购买 nike

我知道这里有很多如何获得处理器体系结构的示例。

这应该在x64上通过true或false检查得到类型

我的问题是:如何将输出转换为if语句?

示例:如果它是64位处理器,则执行一些步骤;如果它是32位处理器,则执行其他步骤。我该如何继续?

我尝试了一些版本的代码,但也得到了true或false的反馈,这还可以,但是如何进一步进行下去?

你们可以帮我吗?

谢谢

最佳答案

谢谢你们。

我通过使用以下解决了它:

$os_type = (Get-WmiObject -Class Win32_ComputerSystem).SystemType -match ‘(x64)’

if ($os_type -eq "True") {
Write-Host "i am an 64bit OS"
write-host $os_type }
else {
$os_type = (Get-WmiObject -Class Win32_ComputerSystem).SystemType -match ‘(x86)’

if ($os_type -eq "True") {
Write-Host "i am a 32 Bit OS" }

关于powershell - 检查处理器体系结构并继续执行if语句,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25407634/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com