WMI Scripting Noob [英] WMI Scripting Noob

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

问题描述

我正在尝试编写一种方法来检查他们是否拥有某个驱动程序,然后查看他们拥有的架构。

I am trying to script a way to check to see if they have a certain driver then what architecture they have.

查看他们是否使用了我使用的正确的NIC。

To see if they have the right NIC I use.

Get-WmiObject -Class CIM_NetworkAdapter -Filter" name =' Broadcom NetXtreme Gigabit Ethernet'"

Get-WmiObject -Class CIM_NetworkAdapter -Filter "name='Broadcom NetXtreme Gigabit Ethernet'"

然后查看他们是否使用64位arch。

Then to see if they have a 64 bit arch I use.

Get-WmiObject -Class Win32_OperatingSystem | Select-Object OSArchitecture

Get-WmiObject -Class Win32_OperatingSystem | Select-Object OSArchitecture

我试图这样做只是为了测试我是否可以让它工作

I tried to do this just for testing to see if I could get it to work

$ nic = Get-WmiObject - CIM_NetworkAdapter -Filter" class ='Broadcom NetXtreme Gigabit Ethernet'" b
$ x =" Broadcom NetXtreme Gigabit Ethernet" b
  if($ nic -eq $ x){Write-Host"Hello Hello我的名字是Bob"}}
   elseif($ nic -ne $ x){写主持人'你好,我的名字是特洛伊'}

$nic = Get-WmiObject -Class CIM_NetworkAdapter -Filter "name='Broadcom NetXtreme Gigabit Ethernet'"
$x = "Broadcom NetXtreme Gigabit Ethernet"
 if ($nic -eq $x) {Write-Host "Hello my name is Bob"}
   elseif ( $nic -ne $x) {Write-Host "Hello, my name is Troy"}

但是它没有任何关于做什么的想法?

But it didnt work any idea on what do to?

并且在子说明中powershell与devcon一起使用?

And on a sub note does powershell work with devcon?

推荐答案

假设存在具有该名称的NIC,

Assuming that a NIC with that name exists,


nic将是对System.Management.ManagementObject实例的引用(如果返回了多个结果,则为对此类对象的数组)。 如果找不到该NIC,
nic will be a reference to a System.Management.ManagementObject instance (or to an array of such objects, if multiple results were returned).  If that NIC wasn't found,


nic将为null,而不是。 你
可以用if(
nic will be null, instead.  You can test for this with if (


这篇关于WMI Scripting Noob的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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