I have been playing with LucD solution to this same problem.
function Get-SnapChild
{
param(
[VMware.Vim.VirtualMachineSnapshotTree]$Snapshot
)
process
{
$snapshot | Select Name, Description, CreateTime
if ($Snapshot.ChildSnapshotList.Count -gt 0)
{
$Snapshot.ChildSnapshotList | % {
Get-SnapChild -Snapshot $_
}
}
}
}
foreach ($vm in Get-View -ViewType VirtualMachine -Property Name, Snapshot -Filter @{'Snapshot' = '' })
{
$vm.Snapshot.RootSnapshotList | % {
Get-SnapChild -Snapshot $_ |
Select @{N = 'VM'; E = { $vm.name } },
@{N = 'Snapshot'; E = { $_.Name } },
@{N = 'Description'; E = { $_.Description } },
@{N = 'CReated'; E = { $_.CreateTime } }
}
}
The only difference is that I am trying to fit a square peg into a round hole and make it fit my report profile which is like:
Get-View -ViewType VirtualMachine -Filter @{'Runtime.PowerState'='poweredOn'} |
Select Name,
@{N='HostName';E={$_.Guest.HostName}},
@{N='Datacenter';E={
$parent = Get-View -Id $_.Parent -Property Name,Parent
while($parent -isnot [VMware.Vim.Datacenter] -and $parent){
$parent = Get-View -Id $parent.Parent -Property Name,Parent
}
if($parent){
$parent.Name
}}},
@{N='Cluster';E={
$parent = Get-View -Id $_.ResourcePool
while($parent -isnot [VMware.Vim.ClusterComputeResource] -and $parent){
$parent = Get-View -Id $parent.Parent -Property Name,Parent
}
if($parent){
$parent.Name}}},
@{N = 'VMHost'; E = {(Get-View -Id $_.Runtime.Host).Name}},
@{N='OS';E={$_.Config.GuestFullName}},
@{N='Boottime';E={$_.Runtime.BootTime}},
@{N='VMState';E={$_.summary.runtime.powerState}},
@{N='IPAddress';E={$_.Guest.ipAddress}},
@{N='MacAddress';E={($_.Config.Hardware.Device | where{$_ -is [VMware.Vim.VirtualEthernetCard]}).MacAddress -join '|'}},
@{N='Portgroup';E={Get-View -Id $vm.Network -Property Name | select -ExpandProperty Name}},
@{N='Memory Total in GB';E={$_.summary.config.memorysizemb.ToString('N0')}},
@{N='DataStore';E={$_.Config.DatastoreUrl[0].Name}},
@{N='Provisioned Space in GB';E={[math]::Round(($vm.Summary.Storage.Committed + $vm.Summary.Storage.UnCommitted)/1GB,2).ToString('N0')}},
@{N='TimeSync';E={$_.Config.Tools.SyncTimeWithHost}},
@{N='ToolsStatus';E={$_.guest.toolsstatus}},
@{N='ToolsVersion';E={$_.config.tools.toolsversion}},
@{N='HardwareVersion';E={$_.config.Version}},
@{N='Site Recovery Manager Group';E={(Get-TagAssignment -Category "SRM Protection Group" -Entity (Get-VIObjectByVIView -VIView $_)).Tag.Name}},
@{n="Networker Policy"; e={$viewThisVM = $_; ($viewThisVM.CustomValue | ?{$_.Key -eq ($viewThisVM.AvailableField | ?{$_.Name -eq "Last EMC vProxy Backup"}).Key}).Value}},
@{N='SnapShot';E={($_.ChildSnapshotList.Name | where{$_ -is [VMware.Vim.VirtualMachineSnapshotTree]})}},
@{N='SnapShot Created';E={($_.ChildSnapshotList.Date | where{$_ -is [VMware.Vim.VirtualMachineSnapshotTree]})}},
@{N='SnapShot Size';E={($_.ChildSnapshotList.Size | where{$_ -is [VMware.Vim.VirtualMachineSnapshotTree]})}}, |
Out-GridView
The Snapshot groups are coming out blank, any help is appreciated.