http://pastebin.com/WemmNbEx
- # emailing list of powered on VMs with snapshots
- # VmWare PowerCLI is required
- $emailTo = "MYMAIL@MYDOMAIN.COM"
- $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"
- }
- }
- $emailFrom = "VM snapshot checker
" - $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"
Комментариев нет:
Отправить комментарий