Hi Team,
Is there any script which we can use for daily check for snapshots which directly comes to our mailbox
Please suggest.
Thanks
What about something like this?
$Report = Get-VM | Get-Snapshot | Select VM,Name,Description,@{Label="Size";Expression={"{0:N2} GB" -f ($_.SizeGB)}},Created
If (-not $Report)
{ $Report = New-Object PSObject -Property @{
VM = "No snapshots found on any VM's controlled by $VIServer"
Name = ""
Description = ""
Size = ""
Created = ""
}
}
$Report = $Report | Select VM,Name,Description,Size,Created | ConvertTo-Html -Head $Header -PreContent "<p><h2>Snapshot Report - $VIServer</h2></p><br>" | Set-AlternatingRows -CSSEvenClass even -CSSOddClass odd
The HTML report above can be then forwarded to your email using a SMTP client.
you can follow this below link and try once this may work.
Or you try with this too
Connect-VIServer Servername
$body = Get-Folder foldername | Get-VM | Get-Snapshot | Select Name, VM, SizeMb | Out-String
Send-MailMessage -From "VMware@vmware.com" -To "user@vmware.com" `
-SmtpServer "name" -Body $body `
-Subject "Snapshot Report"
from PowerShell you can send email with cmd
hi Pwilk,
Sorry for the late response and Thank you for the script but while running it gives me error of " Set-Alternating Rows" is not recognized as cmdlet.
Also i am looking with the categories of
VM | Snapshot name | Description | Created On | Initiated By
please help.
Hi Raghu
Thank you for the reply, but while running the script getting the below error
Get-Folder Folder with name 'foldername' was not found using the specified
So, what exactly we can specify under "Get-folder".
Please suggest.