Usando o PowerShell em uma VM do Azure para recuperar o VHD de discos usados em um pool de armazenamento

1

Estou tentando saber quais VHDs são usados para um pool de armazenamento específico. Usando a CLI de plataforma cruzada, consigo obter o LUN e o nome do blob:

$ azure vm disk list testvm
info:    Executing command vm disk list
+ Fetching disk images                                                         
+ Getting virtual machines                                                     
+ Getting VM disks                                                             
data:    Lun  Size(GB)  Blob-Name                                         OS     
data:    ---  --------  ------------------------------------------------  -------
data:         128       testvm-testvm-os-1457591813350.vhd                Windows
data:    0    1023      testvm-disk1.vhd                                  
data:    1    1023      testvm-disk2.vhd                                  
data:    2    1023      testvm-disk3.vhd                                  
data:    3    1023      testvm-disk4.vhd

Na VM usando o aplicativo Gerenciador de Dispositivos para o pool de armazenamento, consigo obter a letra da unidade, o nome amigável, o tamanho do disco, o ID do disco (o mesmo que é relatado pelo diskpart) e Aba Detalhes, há informações sobre Relações de Poder que listam o LUN:

SCSI\Disk&Ven_Msft&Prod_Virtual_Disk
PS C:\Users\vpjtech> Get-StoragePool -FriendlyName Data | Get-PhysicalDisk

FriendlyName            CanPool                 OperationalStatus       HealthStatus            Usage                                     Size
------------            -------                 -----------------       ------------            -----                                     ----
PhysicalDisk2           False                   OK                      Healthy                 Auto-Select                         1022.25 GB
PhysicalDisk5           False                   OK                      Healthy                 Auto-Select                         1022.25 GB
PhysicalDisk3           False                   OK                      Healthy                 Auto-Select                         1022.25 GB
PhysicalDisk4           False                   OK                      Healthy                 Auto-Select                         1022.25 GB
0003 SCSI\Disk&Ven_Msft&Prod_Virtual_Disk
__GENUS             : 2
__CLASS             : Win32_SCSIControllerDevice
__SUPERCLASS        : CIM_ControlledBy
__DYNASTY           : CIM_Dependency
__RELPATH           : Win32_SCSIControllerDevice.Antecedent="\\TESTVM\root\cimv2:Win32_SCSIController.DeviceID=\"ROOT\\SPACEPORT\
                      \
$ azure vm disk list testvm
info:    Executing command vm disk list
+ Fetching disk images                                                         
+ Getting virtual machines                                                     
+ Getting VM disks                                                             
data:    Lun  Size(GB)  Blob-Name                                         OS     
data:    ---  --------  ------------------------------------------------  -------
data:         128       testvm-testvm-os-1457591813350.vhd                Windows
data:    0    1023      testvm-disk1.vhd                                  
data:    1    1023      testvm-disk2.vhd                                  
data:    2    1023      testvm-disk3.vhd                                  
data:    3    1023      testvm-disk4.vhd
00\"",Dependent="\\TESTVM\root\cimv2:Win32_PnPEntity.DeviceID=\"STORAGE\\DISK\\{BED09DDF-E9A5-11E5-8 0C0-000D3A404FE8}\"" __PROPERTY_COUNT : 7 __DERIVATION : {CIM_ControlledBy, CIM_DeviceConnection, CIM_Dependency} __SERVER : TESTVM __NAMESPACE : root\cimv2 __PATH : \TESTVM\root\cimv2:Win32_SCSIControllerDevice.Antecedent="\\TESTVM\root\cimv2:Win32_SCSIController.De viceID=\"ROOT\\SPACEPORT\\0000\"",Dependent="\\TESTVM\root\cimv2:Win32_PnPEntity.DeviceID=\"STORAGE\\DI SK\\{BED09DDF-E9A5-11E5-80C0-000D3A404FE8}\"" AccessState : Antecedent : \TESTVM\root\cimv2:Win32_SCSIController.DeviceID="ROOT\SPACEPORT\0000" Dependent : \TESTVM\root\cimv2:Win32_PnPEntity.DeviceID="STORAGE\DISK\{BED09DDF-E9A5-11E5-80C0-000D3A404FE8}" NegotiatedDataWidth : NegotiatedSpeed : NumberOfHardResets : NumberOfSoftResets : PSComputerName : TESTVM __GENUS : 2 __CLASS : Win32_SCSIControllerDevice __SUPERCLASS : CIM_ControlledBy __DYNASTY : CIM_Dependency __RELPATH : Win32_SCSIControllerDevice.Antecedent="\\TESTVM\root\cimv2:Win32_SCSIController.DeviceID=\"VMBUS\\{BA6163D9 -04A1-4D29-B605-72E2FFB1DC7F}\\{F8B3781B-1E82-4818-A1C3-63D806EC15BB}\"",Dependent="\\TESTVM\root\cimv2:Win 32_PnPEntity.DeviceID=\"SCSI\\DISK&VEN_MSFT&PROD_VIRTUAL_DISK\\000000\"" __PROPERTY_COUNT : 7 __DERIVATION : {CIM_ControlledBy, CIM_DeviceConnection, CIM_Dependency} __SERVER : TESTVM __NAMESPACE : root\cimv2 __PATH : \TESTVM\root\cimv2:Win32_SCSIControllerDevice.Antecedent="\\TESTVM\root\cimv2:Win32_SCSIController.De viceID=\"VMBUS\\{BA6163D9-04A1-4D29-B605-72E2FFB1DC7F}\\{F8B3781B-1E82-4818-A1C3-63D806EC15BB}\"",Dependent="\\TES TVM\root\cimv2:Win32_PnPEntity.DeviceID=\"SCSI\\DISK&VEN_MSFT&PROD_VIRTUAL_DISK\\000000\"" AccessState : Antecedent : \TESTVM\root\cimv2:Win32_SCSIController.DeviceID="VMBUS\{BA6163D9-04A1-4D29-B605-72E2FFB1DC7F}\{F8B3781B-1E82- 4818-A1C3-63D806EC15BB}" Dependent : \TESTVM\root\cimv2:Win32_PnPEntity.DeviceID="SCSI\DISK&VEN_MSFT&PROD_VIRTUAL_DISK\000000" NegotiatedDataWidth : NegotiatedSpeed : NumberOfHardResets : NumberOfSoftResets : PSComputerName : TESTVM __GENUS : 2 __CLASS : Win32_SCSIControllerDevice __SUPERCLASS : CIM_ControlledBy __DYNASTY : CIM_Dependency __RELPATH : Win32_SCSIControllerDevice.Antecedent="\\TESTVM\root\cimv2:Win32_SCSIController.DeviceID=\"VMBUS\\{BA6163D9 -04A1-4D29-B605-72E2FFB1DC7F}\\{F8B3781B-1E82-4818-A1C3-63D806EC15BB}\"",Dependent="\\TESTVM\root\cimv2:Win 32_PnPEntity.DeviceID=\"SCSI\\DISK&VEN_MSFT&PROD_VIRTUAL_DISK\\000001\"" __PROPERTY_COUNT : 7 __DERIVATION : {CIM_ControlledBy, CIM_DeviceConnection, CIM_Dependency} __SERVER : TESTVM __NAMESPACE : root\cimv2 __PATH : \TESTVM\root\cimv2:Win32_SCSIControllerDevice.Antecedent="\\TESTVM\root\cimv2:Win32_SCSIController.De viceID=\"VMBUS\\{BA6163D9-04A1-4D29-B605-72E2FFB1DC7F}\\{F8B3781B-1E82-4818-A1C3-63D806EC15BB}\"",Dependent="\\TES TVM\root\cimv2:Win32_PnPEntity.DeviceID=\"SCSI\\DISK&VEN_MSFT&PROD_VIRTUAL_DISK\\000001\"" AccessState : Antecedent : \TESTVM\root\cimv2:Win32_SCSIController.DeviceID="VMBUS\{BA6163D9-04A1-4D29-B605-72E2FFB1DC7F}\{F8B3781B-1E82- 4818-A1C3-63D806EC15BB}" Dependent : \TESTVM\root\cimv2:Win32_PnPEntity.DeviceID="SCSI\DISK&VEN_MSFT&PROD_VIRTUAL_DISK\000001" NegotiatedDataWidth : NegotiatedSpeed : NumberOfHardResets : NumberOfSoftResets : PSComputerName : TESTVM __GENUS : 2 __CLASS : Win32_SCSIControllerDevice __SUPERCLASS : CIM_ControlledBy __DYNASTY : CIM_Dependency __RELPATH : Win32_SCSIControllerDevice.Antecedent="\\TESTVM\root\cimv2:Win32_SCSIController.DeviceID=\"VMBUS\\{BA6163D9 -04A1-4D29-B605-72E2FFB1DC7F}\\{F8B3781B-1E82-4818-A1C3-63D806EC15BB}\"",Dependent="\\TESTVM\root\cimv2:Win 32_PnPEntity.DeviceID=\"SCSI\\DISK&VEN_MSFT&PROD_VIRTUAL_DISK\\000002\"" __PROPERTY_COUNT : 7 __DERIVATION : {CIM_ControlledBy, CIM_DeviceConnection, CIM_Dependency} __SERVER : TESTVM __NAMESPACE : root\cimv2 __PATH : \TESTVM\root\cimv2:Win32_SCSIControllerDevice.Antecedent="\\TESTVM\root\cimv2:Win32_SCSIController.De viceID=\"VMBUS\\{BA6163D9-04A1-4D29-B605-72E2FFB1DC7F}\\{F8B3781B-1E82-4818-A1C3-63D806EC15BB}\"",Dependent="\\TES TVM\root\cimv2:Win32_PnPEntity.DeviceID=\"SCSI\\DISK&VEN_MSFT&PROD_VIRTUAL_DISK\\000002\"" AccessState : Antecedent : \TESTVM\root\cimv2:Win32_SCSIController.DeviceID="VMBUS\{BA6163D9-04A1-4D29-B605-72E2FFB1DC7F}\{F8B3781B-1E82- 4818-A1C3-63D806EC15BB}" Dependent : \TESTVM\root\cimv2:Win32_PnPEntity.DeviceID="SCSI\DISK&VEN_MSFT&PROD_VIRTUAL_DISK\000002" NegotiatedDataWidth : NegotiatedSpeed : NumberOfHardResets : NumberOfSoftResets : PSComputerName : TESTVM __GENUS : 2 __CLASS : Win32_SCSIControllerDevice __SUPERCLASS : CIM_ControlledBy __DYNASTY : CIM_Dependency __RELPATH : Win32_SCSIControllerDevice.Antecedent="\\TESTVM\root\cimv2:Win32_SCSIController.DeviceID=\"VMBUS\\{BA6163D9 -04A1-4D29-B605-72E2FFB1DC7F}\\{F8B3781B-1E82-4818-A1C3-63D806EC15BB}\"",Dependent="\\TESTVM\root\cimv2:Win 32_PnPEntity.DeviceID=\"SCSI\\DISK&VEN_MSFT&PROD_VIRTUAL_DISK\\000003\"" __PROPERTY_COUNT : 7 __DERIVATION : {CIM_ControlledBy, CIM_DeviceConnection, CIM_Dependency} __SERVER : TESTVM __NAMESPACE : root\cimv2 __PATH : \TESTVM\root\cimv2:Win32_SCSIControllerDevice.Antecedent="\\TESTVM\root\cimv2:Win32_SCSIController.De viceID=\"VMBUS\\{BA6163D9-04A1-4D29-B605-72E2FFB1DC7F}\\{F8B3781B-1E82-4818-A1C3-63D806EC15BB}\"",Dependent="\\TES TVM\root\cimv2:Win32_PnPEntity.DeviceID=\"SCSI\\DISK&VEN_MSFT&PROD_VIRTUAL_DISK\\000003\"" AccessState : Antecedent : \TESTVM\root\cimv2:Win32_SCSIController.DeviceID="VMBUS\{BA6163D9-04A1-4D29-B605-72E2FFB1DC7F}\{F8B3781B-1E82- 4818-A1C3-63D806EC15BB}" Dependent : \TESTVM\root\cimv2:Win32_PnPEntity.DeviceID="SCSI\DISK&VEN_MSFT&PROD_VIRTUAL_DISK\000003" NegotiatedDataWidth : NegotiatedSpeed : NumberOfHardResets : NumberOfSoftResets : PSComputerName : TESTVM
0001 SCSI\Disk&Ven_Msft&Prod_Virtual_Disk
SCSI\Disk&Ven_Msft&Prod_Virtual_Disk
PS C:\Users\vpjtech> Get-StoragePool -FriendlyName Data | Get-PhysicalDisk

FriendlyName            CanPool                 OperationalStatus       HealthStatus            Usage                                     Size
------------            -------                 -----------------       ------------            -----                                     ----
PhysicalDisk2           False                   OK                      Healthy                 Auto-Select                         1022.25 GB
PhysicalDisk5           False                   OK                      Healthy                 Auto-Select                         1022.25 GB
PhysicalDisk3           False                   OK                      Healthy                 Auto-Select                         1022.25 GB
PhysicalDisk4           False                   OK                      Healthy                 Auto-Select                         1022.25 GB
0003 SCSI\Disk&Ven_Msft&Prod_Virtual_Disk
__GENUS             : 2
__CLASS             : Win32_SCSIControllerDevice
__SUPERCLASS        : CIM_ControlledBy
__DYNASTY           : CIM_Dependency
__RELPATH           : Win32_SCSIControllerDevice.Antecedent="\\TESTVM\root\cimv2:Win32_SCSIController.DeviceID=\"ROOT\\SPACEPORT\
                      \%pre%00\"",Dependent="\\TESTVM\root\cimv2:Win32_PnPEntity.DeviceID=\"STORAGE\\DISK\\{BED09DDF-E9A5-11E5-8
                      0C0-000D3A404FE8}\""
__PROPERTY_COUNT    : 7
__DERIVATION        : {CIM_ControlledBy, CIM_DeviceConnection, CIM_Dependency}
__SERVER            : TESTVM
__NAMESPACE         : root\cimv2
__PATH              : \TESTVM\root\cimv2:Win32_SCSIControllerDevice.Antecedent="\\TESTVM\root\cimv2:Win32_SCSIController.De
                      viceID=\"ROOT\\SPACEPORT\\0000\"",Dependent="\\TESTVM\root\cimv2:Win32_PnPEntity.DeviceID=\"STORAGE\\DI
                      SK\\{BED09DDF-E9A5-11E5-80C0-000D3A404FE8}\""
AccessState         : 
Antecedent          : \TESTVM\root\cimv2:Win32_SCSIController.DeviceID="ROOT\SPACEPORT\0000"
Dependent           : \TESTVM\root\cimv2:Win32_PnPEntity.DeviceID="STORAGE\DISK\{BED09DDF-E9A5-11E5-80C0-000D3A404FE8}"
NegotiatedDataWidth : 
NegotiatedSpeed     : 
NumberOfHardResets  : 
NumberOfSoftResets  : 
PSComputerName      : TESTVM

__GENUS             : 2
__CLASS             : Win32_SCSIControllerDevice
__SUPERCLASS        : CIM_ControlledBy
__DYNASTY           : CIM_Dependency
__RELPATH           : Win32_SCSIControllerDevice.Antecedent="\\TESTVM\root\cimv2:Win32_SCSIController.DeviceID=\"VMBUS\\{BA6163D9
                      -04A1-4D29-B605-72E2FFB1DC7F}\\{F8B3781B-1E82-4818-A1C3-63D806EC15BB}\"",Dependent="\\TESTVM\root\cimv2:Win
                      32_PnPEntity.DeviceID=\"SCSI\\DISK&VEN_MSFT&PROD_VIRTUAL_DISK\\000000\""
__PROPERTY_COUNT    : 7
__DERIVATION        : {CIM_ControlledBy, CIM_DeviceConnection, CIM_Dependency}
__SERVER            : TESTVM
__NAMESPACE         : root\cimv2
__PATH              : \TESTVM\root\cimv2:Win32_SCSIControllerDevice.Antecedent="\\TESTVM\root\cimv2:Win32_SCSIController.De
                      viceID=\"VMBUS\\{BA6163D9-04A1-4D29-B605-72E2FFB1DC7F}\\{F8B3781B-1E82-4818-A1C3-63D806EC15BB}\"",Dependent="\\TES
                      TVM\root\cimv2:Win32_PnPEntity.DeviceID=\"SCSI\\DISK&VEN_MSFT&PROD_VIRTUAL_DISK\\000000\""
AccessState         : 
Antecedent          : \TESTVM\root\cimv2:Win32_SCSIController.DeviceID="VMBUS\{BA6163D9-04A1-4D29-B605-72E2FFB1DC7F}\{F8B3781B-1E82-
                      4818-A1C3-63D806EC15BB}"
Dependent           : \TESTVM\root\cimv2:Win32_PnPEntity.DeviceID="SCSI\DISK&VEN_MSFT&PROD_VIRTUAL_DISK\000000"
NegotiatedDataWidth : 
NegotiatedSpeed     : 
NumberOfHardResets  : 
NumberOfSoftResets  : 
PSComputerName      : TESTVM

__GENUS             : 2
__CLASS             : Win32_SCSIControllerDevice
__SUPERCLASS        : CIM_ControlledBy
__DYNASTY           : CIM_Dependency
__RELPATH           : Win32_SCSIControllerDevice.Antecedent="\\TESTVM\root\cimv2:Win32_SCSIController.DeviceID=\"VMBUS\\{BA6163D9
                      -04A1-4D29-B605-72E2FFB1DC7F}\\{F8B3781B-1E82-4818-A1C3-63D806EC15BB}\"",Dependent="\\TESTVM\root\cimv2:Win
                      32_PnPEntity.DeviceID=\"SCSI\\DISK&VEN_MSFT&PROD_VIRTUAL_DISK\\000001\""
__PROPERTY_COUNT    : 7
__DERIVATION        : {CIM_ControlledBy, CIM_DeviceConnection, CIM_Dependency}
__SERVER            : TESTVM
__NAMESPACE         : root\cimv2
__PATH              : \TESTVM\root\cimv2:Win32_SCSIControllerDevice.Antecedent="\\TESTVM\root\cimv2:Win32_SCSIController.De
                      viceID=\"VMBUS\\{BA6163D9-04A1-4D29-B605-72E2FFB1DC7F}\\{F8B3781B-1E82-4818-A1C3-63D806EC15BB}\"",Dependent="\\TES
                      TVM\root\cimv2:Win32_PnPEntity.DeviceID=\"SCSI\\DISK&VEN_MSFT&PROD_VIRTUAL_DISK\\000001\""
AccessState         : 
Antecedent          : \TESTVM\root\cimv2:Win32_SCSIController.DeviceID="VMBUS\{BA6163D9-04A1-4D29-B605-72E2FFB1DC7F}\{F8B3781B-1E82-
                      4818-A1C3-63D806EC15BB}"
Dependent           : \TESTVM\root\cimv2:Win32_PnPEntity.DeviceID="SCSI\DISK&VEN_MSFT&PROD_VIRTUAL_DISK\000001"
NegotiatedDataWidth : 
NegotiatedSpeed     : 
NumberOfHardResets  : 
NumberOfSoftResets  : 
PSComputerName      : TESTVM

__GENUS             : 2
__CLASS             : Win32_SCSIControllerDevice
__SUPERCLASS        : CIM_ControlledBy
__DYNASTY           : CIM_Dependency
__RELPATH           : Win32_SCSIControllerDevice.Antecedent="\\TESTVM\root\cimv2:Win32_SCSIController.DeviceID=\"VMBUS\\{BA6163D9
                      -04A1-4D29-B605-72E2FFB1DC7F}\\{F8B3781B-1E82-4818-A1C3-63D806EC15BB}\"",Dependent="\\TESTVM\root\cimv2:Win
                      32_PnPEntity.DeviceID=\"SCSI\\DISK&VEN_MSFT&PROD_VIRTUAL_DISK\\000002\""
__PROPERTY_COUNT    : 7
__DERIVATION        : {CIM_ControlledBy, CIM_DeviceConnection, CIM_Dependency}
__SERVER            : TESTVM
__NAMESPACE         : root\cimv2
__PATH              : \TESTVM\root\cimv2:Win32_SCSIControllerDevice.Antecedent="\\TESTVM\root\cimv2:Win32_SCSIController.De
                      viceID=\"VMBUS\\{BA6163D9-04A1-4D29-B605-72E2FFB1DC7F}\\{F8B3781B-1E82-4818-A1C3-63D806EC15BB}\"",Dependent="\\TES
                      TVM\root\cimv2:Win32_PnPEntity.DeviceID=\"SCSI\\DISK&VEN_MSFT&PROD_VIRTUAL_DISK\\000002\""
AccessState         : 
Antecedent          : \TESTVM\root\cimv2:Win32_SCSIController.DeviceID="VMBUS\{BA6163D9-04A1-4D29-B605-72E2FFB1DC7F}\{F8B3781B-1E82-
                      4818-A1C3-63D806EC15BB}"
Dependent           : \TESTVM\root\cimv2:Win32_PnPEntity.DeviceID="SCSI\DISK&VEN_MSFT&PROD_VIRTUAL_DISK\000002"
NegotiatedDataWidth : 
NegotiatedSpeed     : 
NumberOfHardResets  : 
NumberOfSoftResets  : 
PSComputerName      : TESTVM

__GENUS             : 2
__CLASS             : Win32_SCSIControllerDevice
__SUPERCLASS        : CIM_ControlledBy
__DYNASTY           : CIM_Dependency
__RELPATH           : Win32_SCSIControllerDevice.Antecedent="\\TESTVM\root\cimv2:Win32_SCSIController.DeviceID=\"VMBUS\\{BA6163D9
                      -04A1-4D29-B605-72E2FFB1DC7F}\\{F8B3781B-1E82-4818-A1C3-63D806EC15BB}\"",Dependent="\\TESTVM\root\cimv2:Win
                      32_PnPEntity.DeviceID=\"SCSI\\DISK&VEN_MSFT&PROD_VIRTUAL_DISK\\000003\""
__PROPERTY_COUNT    : 7
__DERIVATION        : {CIM_ControlledBy, CIM_DeviceConnection, CIM_Dependency}
__SERVER            : TESTVM
__NAMESPACE         : root\cimv2
__PATH              : \TESTVM\root\cimv2:Win32_SCSIControllerDevice.Antecedent="\\TESTVM\root\cimv2:Win32_SCSIController.De
                      viceID=\"VMBUS\\{BA6163D9-04A1-4D29-B605-72E2FFB1DC7F}\\{F8B3781B-1E82-4818-A1C3-63D806EC15BB}\"",Dependent="\\TES
                      TVM\root\cimv2:Win32_PnPEntity.DeviceID=\"SCSI\\DISK&VEN_MSFT&PROD_VIRTUAL_DISK\\000003\""
AccessState         : 
Antecedent          : \TESTVM\root\cimv2:Win32_SCSIController.DeviceID="VMBUS\{BA6163D9-04A1-4D29-B605-72E2FFB1DC7F}\{F8B3781B-1E82-
                      4818-A1C3-63D806EC15BB}"
Dependent           : \TESTVM\root\cimv2:Win32_PnPEntity.DeviceID="SCSI\DISK&VEN_MSFT&PROD_VIRTUAL_DISK\000003"
NegotiatedDataWidth : 
NegotiatedSpeed     : 
NumberOfHardResets  : 
NumberOfSoftResets  : 
PSComputerName      : TESTVM
0001 SCSI\Disk&Ven_Msft&Prod_Virtual_Disk%pre%0002 SCSI\Disk&Ven_Msft&Prod_Virtual_Disk%pre%0000
0002 SCSI\Disk&Ven_Msft&Prod_Virtual_Disk%pre%0000

Agora estou tentando obter as mesmas informações por meio do PowerShell, mas o melhor que posso encontrar é o nome amigável dos VHDs, o que não é muito útil nesse contexto:

%pre%

Usando o Get-WmiObject, consigo obter o LUN, mas não vejo como posso vincular essas informações ao pool de armazenamento:

PS C: \ Usuários \ vpjtech > Get-WmiObject -Class Win32_SCSIControllerDevice

%pre%

Deve haver um caminho, mas não consigo envolver minha cabeça em torno dele.

    
por Christophe Garrigue 09.12.2016 / 04:41

1 resposta

1

De acordo com sua descrição, eu testei no meu laboratório. Talvez você possa usar o cmdlet abaixo:

Get-WmiObject Win32_DiskDrive | ForEach-Object {
  $disk = $_
  $partitions = "ASSOCIATORS OF " +
                "{Win32_DiskDrive.DeviceID='$($disk.DeviceID)'} " +
                "WHERE AssocClass = Win32_DiskDriveToDiskPartition"
  Get-WmiObject -Query $partitions | ForEach-Object {
    $partition = $_
    $drives = "ASSOCIATORS OF " +
              "{Win32_DiskPartition.DeviceID='$($partition.DeviceID)'} " +
              "WHERE AssocClass = Win32_LogicalDiskToPartition"
    Get-WmiObject -Query $drives | ForEach-Object {
      $driveLetter = $_.DeviceID
      $fltr        = "DriveLetter='$driveLetter'"
      New-Object -Type PSCustomObject -Property @{
        Disk        = $disk.PNPDeviceID
        DriveLetter = $driveLetter
        VolumeName  = $_.VolumeName
        VolumeID    = Get-WmiObject -Class Win32_Volume -Filter $fltr |
                      Select-Object -Expand DeviceID
        Size        = $disk.Size
      } |ft -AutoSize
    }
  }
}

Atenciosamente,

Walter

    
por 09.12.2016 / 11:01