Skip to content

Instantly share code, notes, and snippets.

@gowatana
Last active May 8, 2021 05:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gowatana/b2a7e1d419cf648c3818f7e152100d35 to your computer and use it in GitHub Desktop.
Save gowatana/b2a7e1d419cf648c3818f7e152100d35 to your computer and use it in GitHub Desktop.
PowerCLI で、親 VMDK のパスを表示する。
$vm_name = $args[0]
Get-VM $vm_name | %{
$vm = $_
$vm | Get-HardDisk | %{
$vmdk = $_
$vmdk_table = @()
$vmdk_table += $vmdk.ExtensionData.Backing
$parent = $vmdk.ExtensionData.Backing.Parent
while($parent){
$vmdk_table += $parent
$parent = $Parent.Parent
}
"`nVM-VMDK-Table: $vm -- $vmdk"
$vmdk_table | select Uuid,ContentId,DigestEnabled,DeltaDiskFormat,FileName | ft -AutoSize
"`nVM-VMDK-Name: $vm -- $vmdk"
$vmdk_table | select -ExpandProperty FileName
}
}
@gowatana
Copy link
Author

gowatana commented May 7, 2021

使用例。

PowerCLI> .\get_vmdk_parent.ps1 "vdi-01"

VM-VMDK-Table: vdi-01 -- Hard disk 1

Uuid                                 ContentId                        DeltaDiskFormat FileName
----                                 ---------                        --------------- --------
6000C291-5cc1-6237-edf4-ec3118b9e572 29725fd63492d60cd0bc412ed8512539 seSparseFormat  [Datastore-VMFS-162-B] vdi-01/vdi-01_2-000001.vmdk
6000C291-5cc1-6237-edf4-ec3118b9e572 29725fd63492d60cd0bc412ed8512539 seSparseFormat  [Datastore-VMFS-162-B] vdi-01/vdi-01_2.vmdk
6000C291-5cc1-6237-edf4-ec3118b9e572 29725fd63492d60cd0bc412ed8512539                 [Datastore-VMFS-162-B] cp-replica-a0fba67c-075c-43...



VM-VMDK-Name: vdi-01 -- Hard disk 1
[Datastore-VMFS-162-B] vdi-01/vdi-01_2-000001.vmdk
[Datastore-VMFS-162-B] vdi-01/vdi-01_2.vmdk
[Datastore-VMFS-162-B] cp-replica-a0fba67c-075c-43e7-a9f2-cb752d1e15c2/cp-replica-a0fba67c-075c-43e7-a9f2-cb752d1e15c2_2.vmdk

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment