如何发现设备属性及其PowerShell / WMI等价物?

时间:2014-08-17 06:57:06

标签: powershell wmi wmi-query

我有这个powershell代码(我没有写它):

$nics = Get-WmiObject Win32_NetworkAdapter -filter "AdapterTypeID = '0' `
                                                    AND PhysicalAdapter = 'true' `
                                                    AND NOT Description LIKE '%Centrino%' `
                                                    AND NOT Description LIKE '%wireless%' `
                                                    AND NOT Description LIKE '%WiFi%' `
                                                    AND NOT Description LIKE '%Bluetooth%'"


foreach ($nic in $nics)
  {
  $nicName = $nic.Name
   ...
}

问题

作者是如何知道NIC具有这些属性的:

  • Win32_NetworkAdapter
  • AdapterTypeID
  • PhysicalAdapter
  • 说明

换句话说:我如何检查NIC / Other_Device具有的所有属性?

1 个答案:

答案 0 :(得分:1)

get-member或(gm)为您提供所有属性:

PS C:\Users\bjorn> Get-WmiObject Win32_NetworkAdapter | gm


   TypeName: System.Management.ManagementObject#root\cimv2\Win32_NetworkAdapter

Name                        MemberType    Definition                                                                                        
----                        ----------    ----------                                                                                        
PSComputerName              AliasProperty PSComputerName = __SERVER                                                                         
Disable                     Method        System.Management.ManagementBaseObject Disable()                                                  
Enable                      Method        System.Management.ManagementBaseObject Enable()                                                   
Reset                       Method        System.Management.ManagementBaseObject Reset()                                                    
SetPowerState               Method        System.Management.ManagementBaseObject SetPowerState(System.UInt16 PowerState, System.String Time)
AdapterType                 Property      string AdapterType {get;set;}                                                                     
AdapterTypeId               Property      uint16 AdapterTypeId {get;set;}                                                                   
AutoSense                   Property      bool AutoSense {get;set;}                                                                         
Availability                Property      uint16 Availability {get;set;}    
...

或与... ISESteroids插件:

enter image description here