Hi Luc,
I looked at this scripts but it using connection to ESX hosts as well as to Guest OS which is some cases not workable for me.
I tried to scripts from PowrGui "VMware Community PowerPack" and they giving me information i need but in two different places. I don't know how to combine them so I have one output.
Scripit one "VM Guest Disk Space":
if
($global:defaultviservers) {
$AllVMs = Get-View -ViewType VirtualMachine | Where {-not $_.Config.Template}
$SortedVMs = $AllVMs | Select *, @{N="NumDisks";E={@($_.Guest.Disk.Length)}} | Sort-Object -Descending NumDisks
ForEach ($VM in $SortedVMs){
$Details = New-object PSObject
$Details | Add-Member -Name Name -Value $VM.name -Membertype NoteProperty
$DiskNum = 0
Foreach ($disk in $VM.Guest.Disk){
$Details | Add-Member -Name "Disk$($DiskNum)path" -MemberType NoteProperty -Value $Disk.DiskPath
$Details | Add-Member -Name "Disk$($DiskNum)Capacity(MB)" -MemberType NoteProperty -Value ([math]::Round($disk.Capacity/ 1MB))
$Details | Add-Member -Name "Disk$($DiskNum)FreeSpace(MB)" -MemberType NoteProperty -Value ([math]::Round($disk.FreeSpace / 1MB))
$DiskNum++
}
$Details.PSTypeNames.Clear()
$Details.PSTypeNames.Add('Virtu-al.PowerPack.VMGuestDisks')
$Details.PSTypeNames.Add('Virtu-al.PowerPack.VM')
$Details
}
}
Else
{
[
System.Windows.Forms.MessageBox]::Show('You must connect to one or more hosts before you can use this node. Please click on the ''Managed Hosts'' node of the VMware PowerPack, connect to one or more of the servers you have configured there, and then try again.','Connection not established',[System.Windows.Forms.MessageBoxButtons]::OK,[System.Windows.Forms.MessageBoxIcon]::Information) | Out-Null
}
Script two "VM VMDK Information":
# Thanks to ICT-FREAK.NL - http://ict-freak.nl/2009/10/11/powercli-virtual-machine-disk-vmdk-info-v2-analyze-data-with-excel/
if
($global:defaultviservers) {
foreach($vm in (get-view -ViewType VirtualMachine | Where-Object {-not $_.config.template})){
foreach($dev in $vm.config.hardware.Device) {
$Details = "" | Select-Object VMName, DeviceLabel, FileName, DiskMode, ThinProvisioned
$Details.VMName = $vm.Name
if ($dev.GetType().Name -eq "VirtualDisk") {
$Details.DeviceLabel = $dev.DeviceInfo.Label
$Details.FileName = $dev.Backing.FileName
$Details.DiskMode = $dev.Backing.DiskMode
if($dev.Backing.ThinProvisioned) {
$Details.ThinProvisioned = "True"
}
else {
$Details.ThinProvisioned = "False"
}
$Details.PSTypeNames.Clear()
$Details.PSTypeNames.Add('Virtu-al.PowerPack.VMVMDKInfo')
$Details.PSTypeNames.Add('Virtu-al.PowerPack.VM')
$Details
}
}
}
}
Else
{
[
System.Windows.Forms.MessageBox]::Show('You must connect to one or more hosts before you can use this node. Please click on the ''Managed Hosts'' node of the VMware PowerPack, connect to one or more of the servers you have configured there, and then try again.','Connection not established',[System.Windows.Forms.MessageBoxButtons]::OK,[System.Windows.Forms.MessageBoxIcon]::Information) | Out-Null
}
thanks,
Evgeny