手机
当前位置:查字典教程网 >脚本专栏 >PowerShell >Powershell小技巧之使用WMI查询插上的U盘
Powershell小技巧之使用WMI查询插上的U盘
摘要:如果你想知道当前插在你电脑上的USB设备,WMI能帮助你:Get-WmiObject-ClassWin32_PnPEntity|Where-...

如果你想知道当前插在你电脑上的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查询插上的U盘】相关文章:

Powershell学习笔记--使用正则表达式查找文件

PowerShell中的$Input变量使用实例

PowerShell中使用正则表达式匹配字符串实例

Powershell中调用邮件客户端发送邮件的例子

Windows Powershell Switch 语句

Powershell使用WPF技术实现弹窗提示实例

PowerShell中使用return语句退出函数例子

探索PowerShell(十四) 使用WMI对象的方法

PowerShell函数中使用必选参数实例

PowerShell中使用正则表达式跨行匹配字符串的方法

精品推荐
分类导航