如果你想知道当前插在你电脑上的USB设备,WMI能帮助你:
Get-WmiObject -Class Win32_PnPEntity | Where-Object { $_.DeviceID -like 'USBSTOR*' }
这将返回所有插上在使用的USBSTOR设备类
如果你使用WMI查询语言(WQL),你甚至可以使用筛选命令:
Get-WmiObject -Query 'Select * From Win32_PnPEntity where DeviceID Like "USBSTOR%"'
本方法适合所有的powershell版本
您可能感兴趣的文章:
- 探索PowerShell(十三) WMI对象介绍
- 探索PowerShell(十四) 使用WMI对象的方法
- Powershell小技巧之使用WMI测试服务响应
- PowerShell入门教程之访问.Net程序集、COM和WMI实例
- Powershell小技巧之使用WMI工具
本文由 华域联盟 原创撰写:华域联盟 » Powershell小技巧之使用WMI查询插上的U盘
转载请保留出处和原文链接:https://www.cnhackhy.com/14435.htm