Hi,
I have few methods to report some snapshots from my enviroment:
First method:
Get-VM | %{$vm = $_.Name ; $_ | Get-Snapshot | Where { $_.Name -like "auto-*"} | Measure-Object | %{write-host $vm $_.Count}}
VM Name Snapshots with "auto" in name
VM1 2
VM2 1
With this method I can get what I want: VM name and number of snapshots with "auto" word found in name but exporting to HTML only generate a blank file
Second method:
$ss = Get-vm | Get-Snapshot
#$ss | Select-Object vm, name, description, powerstate | ConvertTo-HTML -head $a -body "<H2>VM Snapshot Report</H2>"| Out-File $filename
$ss | Select-Object vm, name, description | ConvertTo-HTML -head $a -body "<H2>VM Snapshot Report</H2>"| Out-File $filename
VM Name Snapshot name
VM1 snapshot1
VM1 snapshot2
VM2 snapshot2
VM2 snapshot3
This method is working but I'm able to get only VM name on one column and each snapshot with name from each VM.
I've already tried all kind of tricks to generate a report with VM name on one column and number of snapshots with "auto" in name but none of this are working.
Not sure I understand what you want in the report.
If you only want the name of the VM and the number of snapshots with auto in the name, the first snippet is doing that.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Or do you mean like this?
Select Name,
@{N='AutoSnap#';E={(Get-SNapshot -VM $_ | where{$_.Name -match 'auto-'}).Count}}}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Try like this
Select Name,
@{N='AutoSnap#';E={(Get-SNapshot -VM $_ | where{$_.Name -match 'auto-'}).Count}} |
ConvertTo-Html | Out-String | Set-Content -Path .\report.html
Invoke-Item -Path .\report.html
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference