Hi
I did a quick look in PowerCLI (including extensiondata, excluding Onyx) and in the community but couldn't find this.
If I wanted to find out the virtual HDs of the VM, specifically if it's thick or thin (that's easy) but more specifically what sub-type - thick/lazy, thick/eager, etc.
I don't need a full script just an example of one VM - I can put in the fillers around it.
Thank you
Afaik some of that info is only available/required when you create a vDisk.
The following will give you some information
$vm = Get-VM MyVM
$vm.ExtensionData.Config.Hardware.Device |
where {$_ -is [VMware.Vim.VirtualDisk]} |
Select @{N="VM";E={$vm.Name}},
@{N="HD";E={$_.DeviceInfo.Label}},
@{N="Type";E={$_.Backing.GetType().Name}},
@{N="EagerlyScrub";E={$_.Backing.EagerlyScrub}},
@{N="ThinProvisioned";E={$_.Backing.ThinProvisioned}}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Afaik some of that info is only available/required when you create a vDisk.
The following will give you some information
$vm = Get-VM MyVM
$vm.ExtensionData.Config.Hardware.Device |
where {$_ -is [VMware.Vim.VirtualDisk]} |
Select @{N="VM";E={$vm.Name}},
@{N="HD";E={$_.DeviceInfo.Label}},
@{N="Type";E={$_.Backing.GetType().Name}},
@{N="EagerlyScrub";E={$_.Backing.EagerlyScrub}},
@{N="ThinProvisioned";E={$_.Backing.ThinProvisioned}}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi Luc
Thanks for the pointer! I took your suggested and fiddled with a test VM to see how the response looks for each. I added three HDs, each with a different flavor of HDs:
hd3 - thick lazy
VM : myvm
HD : Hard disk 3
Type : VirtualDiskFlatVer2BackingInfo
EagerlyScrub :
ThinProvisioned : False
hd4 - thick eager
VM : myvm
HD : Hard disk 4
Type : VirtualDiskFlatVer2BackingInfo
EagerlyScrub : True
ThinProvisioned : False
hd5 - thin
VM : myvm
HD : Hard disk 5
Type : VirtualDiskFlatVer2BackingInfo
EagerlyScrub :
ThinProvisioned : True
So it looks like this:
If HD is thick lazy, eagerlyscrub is null, thinPro flag is false
If HD is thick eager, eageryscrub it true, thinPro flag is false
If HD is thin, eagerlyscrub it nul, thinPro flag is true.
This is a big help. It would nice if this was clearly called out under the "get-HardDisk" cmdlet but this is an excellent workaround.
Thanks
Alan
OK - this seems to be working in our environment. Thanks again LucD - if the formatting is messed up I aplogize ahead of time
Connect-VIServer
myVcenter
$report = @()
#Sets path to where the report will be sent to...this will go to your desktop
$path = $HOME + '\desktop\VM_Disk_Detail.csv'
#gets all the VMs in the vCenter servers
$vmx = Get-VM | sort name
foreach
($vm in $vmx)
{
#Pull in the HDs associated with the VM
#If you just want to see Thin disks, REM line one, unREM line two
vmhds = $vm | Get-HardDisk
#vmhds = $vm | Get-HardDisk | where {$_.StorageFormat -eq 'Thin'}
foreach ($vmhd in $vmhds)
{
$diskStyle = $null
#Boolean field to see if disk is thin provisioned or not
thinPro = $vmhd.extensiondata.backing.thinprovisioned
#Indicates where the disk is thick or thin
$format = $vmhd.StorageFormat
#This will be null for thin disks and thick lazy-zero disks, should be true for thick eager-zero
eager = $vmhd.extensiondata.backing.Eagerlyscrub
#This will determine what the true format is. If it can't decide, disk type is unknown or 'UNK'
if ($eager -eq $null -and $format -eq 'Thick'){$diskStyle = 'ThickLazyZero'}
elseif ($eager -eq 'True' -and $format -eq 'Thick'){$diskStyle = 'ThickEagerZero'}
elseif ($format -eq 'Thin'){$diskStyle = 'ThinProv'}
else {$diskStyle = "UNK"}
$list = '' | select vmName,vmCluster,vmHDname,diskMode,eagerScrub,diskFormat,TP_TF,style,filename
$list.vmname = $vm.Name
$list.vmCluster = $vm.VMHost.Parent
$list.vmHDname = $vmhd.name
$list.diskMode = $vmhd.Persistence
$list.eagerScrub = $eager
$list.diskformat = $vmhd.StorageFormat
$list.TP_TF = $thinPro
$list.style = $diskStyle
$list.filename = $vmhd.filename
$report += $list
}
}
$report | Export-Csv -NoTypeInformation -Path $path
Useful script, thanks for sharing.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
You can use below powercli command, if you dont want to run any script.
Get-VM | Get-HardDisk | select parent,storageformat,name,filename,disktype
Below VM does not have eager zero disk
Parent | : VM name will be shown |
StorageFormat : Thick
Name | : Hard disk 1 |
Filename | : datastore and vmdk name will be shown |
DiskType | : Flat |
And Below VM does have eager zero disk thick provision disk
Parent | : VM name will be shown |
StorageFormat : EagerZeroedThick
Name | : Hard disk 1 |
Filename | : datastore and vmdk name will be shown |
DiskType | : Flat |
You can show up other fields also, like disk size, persistent or non persistent etc...
Thanks for the script @ae_jenkins! It works great and I can easily identify all the disks that need to change format in my environment.