Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # emailing list of powered on VMs with snapshots
- # VmWare PowerCLI is required
- $smtpServer = "smtp_server"
- $vcenter_server = "vcenter_server"
- Add-PSSnapin VMware.VimAutomation.Core
- Connect-VIServer -Server $vcenter_server
- $VM_list = Get-VM | ForEach-Object {
- $snapshot_state = Get-Snapshot $_.Name
- if ( ($_.PowerState -eq 'PoweredOn') -and ($snapshot_state -ne $null) ) {
- "$_ `n"
- }
- }
- $subject = "Powered On VMs with snapshots"
- $body = "$VM_list"
- $smtp = new-object Net.Mail.SmtpClient($smtpServer)
- if ($body -ne $null) { $smtp.Send($emailFrom, $emailTo, $subject, $body)}
- "ok"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement