我想在我的电脑上获得音量索引。
一个例子:
如果我们列出音量,下面是输出:
Volume ### Ltr Label Fs Type Size Status Info
---------- --- ----------- ----- ---------- ------- --------- --------
Volume 0 D CD-ROM 0 B No Media
Volume 1 System Rese NTFS Partition 350 MB Healthy System
Volume 2 C NTFS Partition 39 GB Healthy Boot
Volume 3 I software NTFS Partition 17 GB Healthy
卷索引为0,1,2,3
我可以使用Power shell命令获取这些索引,而不是解析list volume命令的输出吗?
答案 0 :(得分:0)
您可能正在搜索此代码段:
Get-WMIObject -Class Win32_DiskDrive | Select-Object Index
获取所有驱动器的索引。
如果您想在驱动器之间进行区分,可以轻松获得其他信息,例如:
Get-WMIObject -Class Win32_DiskDrive | Select-Object model,name, index
Win32_DiskDrive
类的所有可用属性均为:
TypeName: System.Management.ManagementObject#root\cimv2\Win32_DiskDrive
Name MemberType Definition
---- ---------- ----------
PSComputerName AliasProperty PSComputerName = __SERVER
Reset Method System.Management.ManagementBaseObject Reset()
SetPowerState Method System.Management.ManagementBaseObject SetPowerState(System.UInt16 PowerState, Syste... Availability Property uint16 Availability {get;set;}
BytesPerSector Property uint32 BytesPerSector {get;set;}
Capabilities Property uint16[] Capabilities {get;set;}
CapabilityDescriptions Property string[] CapabilityDescriptions {get;set;}
Caption Property string Caption {get;set;}
CompressionMethod Property string CompressionMethod {get;set;}
ConfigManagerErrorCode Property uint32 ConfigManagerErrorCode {get;set;}
ConfigManagerUserConfig Property bool ConfigManagerUserConfig {get;set;}
CreationClassName Property string CreationClassName {get;set;}
DefaultBlockSize Property uint64 DefaultBlockSize {get;set;}
Description Property string Description {get;set;}
DeviceID Property string DeviceID {get;set;}
ErrorCleared Property bool ErrorCleared {get;set;}
ErrorDescription Property string ErrorDescription {get;set;}
ErrorMethodology Property string ErrorMethodology {get;set;}
FirmwareRevision Property string FirmwareRevision {get;set;}
Index Property uint32 Index {get;set;}
InstallDate Property string InstallDate {get;set;}
InterfaceType Property string InterfaceType {get;set;}
LastErrorCode Property uint32 LastErrorCode {get;set;}
Manufacturer Property string Manufacturer {get;set;}
MaxBlockSize Property uint64 MaxBlockSize {get;set;}
MaxMediaSize Property uint64 MaxMediaSize {get;set;}
MediaLoaded Property bool MediaLoaded {get;set;}
MediaType Property string MediaType {get;set;}
MinBlockSize Property uint64 MinBlockSize {get;set;}
Model Property string Model {get;set;}
Name Property string Name {get;set;}
NeedsCleaning Property bool NeedsCleaning {get;set;}
NumberOfMediaSupported Property uint32 NumberOfMediaSupported {get;set;}
Partitions Property uint32 Partitions {get;set;}
PNPDeviceID Property string PNPDeviceID {get;set;}
PowerManagementCapabilities Property uint16[] PowerManagementCapabilities {get;set;}
PowerManagementSupported Property bool PowerManagementSupported {get;set;}
SCSIBus Property uint32 SCSIBus {get;set;}
SCSILogicalUnit Property uint16 SCSILogicalUnit {get;set;}
SCSIPort Property uint16 SCSIPort {get;set;}
SCSITargetId Property uint16 SCSITargetId {get;set;}
SectorsPerTrack Property uint32 SectorsPerTrack {get;set;}
SerialNumber Property string SerialNumber {get;set;}
Signature Property uint32 Signature {get;set;}
Size Property uint64 Size {get;set;}
Status Property string Status {get;set;}
StatusInfo Property uint16 StatusInfo {get;set;}
SystemCreationClassName Property string SystemCreationClassName {get;set;}
SystemName Property string SystemName {get;set;}
TotalCylinders Property uint64 TotalCylinders {get;set;}
TotalHeads Property uint32 TotalHeads {get;set;}
TotalSectors Property uint64 TotalSectors {get;set;}
TotalTracks Property uint64 TotalTracks {get;set;}
TracksPerCylinder Property uint32 TracksPerCylinder {get;set;}