Hi guys,
Stupid question maybe. I am using this script to list the open snapshots and mail them to our team. Question I got now is the following. Is it possible to add the size of the snapshot in the report? How should I do that?
#Setup email client
+ $SmtpClient = New-Object system.net.mail.smtpClient+
+ $MailMessage = New-Object system.net.mail.mailmessage+
+ $SmtpClient.host = "smtpserver"+
+ $MailMessage.from = "sdfsdfsdf"+
+ $MailMessage.To.add("sdfsdfsdfsdfs")+
+ $MailMessage.IsBodyHtml = 1+
+ $MailMessage.Subject = "Current Vmware Snapshots"+
#Get snapshots from all servers
+ Connect-VIServer virtualcenterserver+
+ $Snaps = @()+
+ get-vm | get-snapshot | %{+
+ $Snap = {} | Select VM,Name,Created,Description+
+ $Snap.VM = $_.vm.name+
+ $Snap.Name = $_.name+
+ $Snap.Created = $_.created+
+ $Snap.Description = $_.description+
+ $Snaps = $Snap
+ }+
+ $MailMessage.body = $Snaps | Sort VM | Select VM,Name,Created,Description | ConvertTo-Html+
+ $SmtpClient.Send($MailMessage)+
Another question is how do I call the powershell script including the VI toolkit. Now I initialize the VI toolkit each time by adding the following in the script
Add-PSSnapin VMware.VimAutomation.Core
Initialize-VIToolkitEnvironment.ps1
Stupid question maybe. I am using this script to list the open snapshots and mail them to our team. Question I got now is the following. Is it possible to add the size of the snapshot in the report? How should I do that?
#Setup email client
+ $SmtpClient = New-Object system.net.mail.smtpClient+
+ $MailMessage = New-Object system.net.mail.mailmessage+
+ $SmtpClient.host = "smtpserver"+
+ $MailMessage.from = "
+ $MailMessage.To.add("
+ $MailMessage.IsBodyHtml = 1+
+ $MailMessage.Subject = "Current Vmware Snapshots"+
#Get snapshots from all servers
+ Connect-VIServer virtualcenterserver+
+ $Snaps = @()+
+ get-vm | get-snapshot | %{+
+ $Snap = {} | Select VM,Name,Created,Description+
+ $Snap.VM = $_.vm.name+
+ $Snap.Name = $_.name+
+ $Snap.Created = $_.created+
+ $Snap.Description = $_.description+
+ $Snaps = $Snap
+ }+
+ $MailMessage.body = $Snaps | Sort VM | Select VM,Name,Created,Description | ConvertTo-Html+
+ $SmtpClient.Send($MailMessage)+
Another question is how do I call the powershell script including the VI toolkit. Now I initialize the VI toolkit each time by adding the following in the script
Add-PSSnapin VMware.VimAutomation.Core
Initialize-VIToolkitEnvironment.ps1
Tags:
snapshots