[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖

[转载代码] [PowerShell每日技巧]列出“真正的”硬盘分区(20131125)

WMI can provide lots of information about a system, but sometimes it is just a bit too much. So when you query for logical disks, you often get back many more than just the physical ones.

Setting an additional filter will do. This line returns only physical drives by making sure that only instances with a DriveType=3 are returned:

PS C:\> Get-WmiObject -Class Win32_LogicalDisk -Filter 'DriveType=3'

DeviceID     : C:
DriveType    : 3
ProviderName :
FreeSpace    : 60000000000
Size         : 100000000000
VolumeName   :

DeviceID     : D:
DriveType    : 3
...


Since Get-WmiObject has a parameter -ComputerName, you can get this information remotely as well. And if you'd like to know what other drive types are there, simply remove the filter or visit a preferred search engine and search for "Win32_LogicalDisk DriveType".

http://powershell.com/cs/blogs/tips/archive/2013/11/25/listing-quot-real-quot-hard-drives.aspx

返回列表