国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發(fā) > PowerShell > 正文

Powershell小技巧之使用WMI工具

2020-03-26 19:13:28
字體:
來源:轉載
供稿:網(wǎng)友

WMI是一個強大的技術:只需要簡單的指定一個WMI類名就能返回它類的所有實例:

 

復制代碼 代碼如下:

PS> Get-WmiObject -Class Win32_BIOS

 

SMBIOSBIOSVersion : 76CN27WW
Manufacturer      : LENOVO
Name              : 76CN27WW
SerialNumber      : 1006250300406
Version           : LENOVO - 1

 

你如何知道它有哪些類呢?這里有一款查找工具:

 

復制代碼 代碼如下:

function Find-WMIClass
{
   param
   (
      [Parameter(Mandatory=$true)]
      $SearchTerm = 'Resolution'
   )
  
   Get-WmiObject -Class * -List |
   Where-Object { $_.Properties.Count -ge 3 } |
   Where-Object { $_.Name -notlike 'Win32_Perf*'  } |
   Where-Object {
      $ListOfNames = $_.Properties | Select-Object -ExpandProperty Name
      ($ListOfNames -like "*$SearchTerm*") -ne $null
   } |
   Sort-Object -Property Name 
}

 

設置搜索條件后,代碼將搜索出包含指定屬性名的類(還可以通過通配符擴大搜索范圍)

下面將找出所有包含“resolution”結尾的WMI類:

 

復制代碼 代碼如下:

PS> Find-WMIClass -SearchTerm *resolution

 

   NameSpace: ROOT/cimv2

Name                                Methods              Properties              
----                                -------              ----------              
CIM_CacheMemory                     {SetPowerState, R... {Access, AdditionalErr...
CIM_CurrentSensor                   {SetPowerState, R... {Accuracy, Availabilit...
CIM_FlatPanel                       {SetPowerState, R... {Availability, Caption...
CIM_Memory                          {SetPowerState, R... {Access, AdditionalErr...
CIM_MonitorResolution               {}                   {Caption, Description,...
CIM_NonVolatileStorage              {SetPowerState, R... {Access, AdditionalErr...
CIM_NumericSensor                   {SetPowerState, R... {Accuracy, Availabilit...
CIM_PCVideoController               {SetPowerState, R... {AcceleratorCapabiliti...
CIM_PointingDevice                  {SetPowerState, R... {Availability, Caption...
CIM_Printer                         {SetPowerState, R... {Availability, Availab...
CIM_Tachometer                      {SetPowerState, R... {Accuracy, Availabilit...
CIM_TemperatureSensor               {SetPowerState, R... {Accuracy, Availabilit...
CIM_VideoController                 {SetPowerState, R... {AcceleratorCapabiliti...
CIM_VideoControllerResolution       {}                   {Caption, Description,...
CIM_VolatileStorage                 {SetPowerState, R... {Access, AdditionalErr...
CIM_VoltageSensor                   {SetPowerState, R... {Accuracy, Availabilit...
Win32_CacheMemory                   {SetPowerState, R... {Access, AdditionalErr...
Win32_CurrentProbe                  {SetPowerState, R... {Accuracy, Availabilit...
Win32_DisplayControllerConfigura... {}                   {BitsPerPixel, Caption...
Win32_MemoryArray                   {SetPowerState, R... {Access, AdditionalErr...
Win32_MemoryDevice                  {SetPowerState, R... {Access, AdditionalErr...
Win32_NetworkAdapterConfiguration   {EnableDHCP, Rene... {ArpAlwaysSourceRoute,...
Win32_PointingDevice                {SetPowerState, R... {Availability, Caption...
Win32_Printer                       {SetPowerState, R... {Attributes, Availabil...
Win32_PrinterConfiguration          {}                   {BitsPerPel, Caption, ...
Win32_SMBIOSMemory                  {SetPowerState, R... {Access, AdditionalErr...
Win32_TemperatureProbe              {SetPowerState, R... {Accuracy, Availabilit...
Win32_VideoConfiguration            {}                   {ActualColorResolution...
Win32_VideoController               {SetPowerState, R... {AcceleratorCapabiliti...
Win32_VoltageProbe                  {SetPowerState, R... {Accuracy, Availabilit...

 

接著,就可以使用類名查看它的有效數(shù)據(jù)啦:

 

復制代碼 代碼如下:

PS> Get-WmiObject -Class CIM_CacheMemory | Select-Object -Property *

 

心得:

其實有個類似功能的圖形工具比這段代碼更方便更直觀,它叫ScriptomaticV2。

支持Powershell所有版本

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 昭通市| 竹溪县| 清苑县| 阿勒泰市| 滦南县| 岢岚县| 兴安县| 扎赉特旗| 留坝县| 桐庐县| 都昌县| 宁远县| 澎湖县| 虎林市| 阜南县| 抚顺市| 石楼县| 莱芜市| 仁寿县| 黑水县| 宝山区| 会宁县| 稻城县| 全椒县| 天柱县| 新闻| 民县| 阿鲁科尔沁旗| 固安县| 马公市| 十堰市| 金堂县| 永安市| 建昌县| 府谷县| 漳浦县| 天峨县| 皮山县| 通河县| 额尔古纳市| 黑龙江省|