- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The HTML report produced by that script already has a column, called NeedsConsolidation, that displays that value.
Not sure what you are asking ?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks Luc, I added that field onto the HTML report but that recalls nothing which is why I need expert help ![]()
If you can have a look at the script and advise what I need to add in order to get that field populated onto the report then it would be very nice
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
get-vm | get-snapshot | %{
$Snap = {} | Select VM,Name,Created,Description,Host,NeedsConsolidation
$Snap.VM = $_.vm.name
$Snap.Name = $_.name
$Snap.Created = $_.created
$Snap.Description = $_.description
$Snap.Host = $_.vm.host.name
$snap.NeedsConsolidation = (get-vm $_.vm).ExtensionData.Runtime.consolidationNeeded
$Report += $Snap
} }Add the BOLD parts
And change the line :
| Write-Output "<td>$($snapshot.vm)</td><td>$($snapshot.name)</td><td>$($snapshot.created)</td><td>$($snapshot.description)</td><td>$($snapshot.host)</td><td>$($snapshot.NeedsConsolidation)</td><tr> " | } |
1) The <td> before snapshot had a "/" in it which needs to be removed
2) $snapshot.consolidationNeeded needs to be changed to NeedsConsolidation because that is what's in $Snap
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You were nearly there (and there is no need to do another Get-VM).
Replace the commented out line
$snap.NeedsConsolidation = $_.ExtensionData.Runtime.consolidationNeeded
by
$snap.NeedsConsolidation = $_.Vm.ExtensionData.Runtime.consolidationNeeded
and add the new property on the Select line
$Snap = {} | Select VM,Name,Created,Description,Host,NeedsConsolidation
and finally correct the propertyname on the output line
Write-Output "<td>$($snapshot.vm)</td><td>$($snapshotname)</td><td>$($snapshot.created)</td><td>$($snapshot.description)</td><td>$($snapshot.host)</td></td>$($snapshot.NeedsConsolidation)</td><tr> "
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Ah good to know ![]()
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks Wh33ly ![]()
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks a lot LucD, worked like a charm ![]()
Now just waiting for it to populate the filed with 'Yes' when consolidation is required for any VM, fingers crossed
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi LucD, sorry I am re opening this thread
the script is working fine except the fact that the NeedsConsloidation column is not displaying me with a Yes
if a VM needs a consolidation . It does show on the vsphere but not via the script
Any ideas?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Would you mind attaching the version you are currently using ?
There were several changes suggested, and I don't know what you are actually using now.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Are you sure you have VMs with a snapshot, and that need consolidation ?
I use the following to find VMs that need consolidation.
$splatVM = @{
ViewType = "VirtualMachine"
Property = "Name","Runtime.ConsolidationNeeded"
Filter = @{"Runtime.ConsolidationNeeded"="True"}
}
Get-View @splatVM | Select Name
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes, we have few VM's which shows needs consolidation in vsphere but not when the script is run, it shows every field but without the Consolidation one
Where do I add these lines in the code to get it populated on the report?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Your original report will only show VMs that have at least 1 snapshot.
The VMs requiring consolidation most probably do not have any snapshots, that is probably the reason you do not see any value in that column.
Did my previous short script show any VMs requiring consolidation ?
Do any of these VMs have snapshots ?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Ok i see
I am not very much concerned about the snapshot but no harm having it
I use get-vm | where {$_.ExnetnsionData.Runtime.consolidationNeeded}| Select Name snippet to list the VM's which needs consolidation and it does show me few VM's which needs manual intervention but the only thing is that its not showing on the report.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
That is because you are doing
get-vm | get-snapshot | %{
Only VMs that have a snapshot will get through.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
So you have suggestions for me on how to get that populated into the report?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Try something along these lines
foreach($vm in Get-VM){
if($vm.ExtensionData.Runtime.ConsolidationNeeded){
$Snap = "" | Select VM,Name,Created,Description,Host,NeedsConsolidation
$Snap.VM = $vm.Name
$snap.NeedsConsolidation = $true
$Report += $Snap
}
else{
Get-Snapshot -VM $vm | %{
$Snap = "" | Select VM,Name,Created,Description,Host,NeedsConsolidation
$Snap.VM = $vm.name
$Snap.Name = $_.name
$Snap.Created = $_.created
$Snap.Description = $_.description
$Snap.Host = $_.vm.host.name
$snap.NeedsConsolidation = $false
$Report += $Snap
}
}
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Wow, worked flawlessly ![]()
Thanks a lot Sir, you rock