2012-01-15

Получение списка виртуальных машин VmWare, содержащих снапшоны



http://pastebin.com/WemmNbEx





  1. # emailing list of powered on VMs with snapshots
  2. # VmWare PowerCLI is required
  3. $emailTo = "MYMAIL@MYDOMAIN.COM"
  4. $smtpServer = "smtp_server"
  5. $vcenter_server = "vcenter_server"
  6. Add-PSSnapin VMware.VimAutomation.Core
  7. Connect-VIServer -Server $vcenter_server
  8. $VM_list = Get-VM | ForEach-Object {
  9.                         $snapshot_state = Get-Snapshot $_.Name
  10.                         if ( ($_.PowerState -eq 'PoweredOn') -and ($snapshot_state -ne $null) ) {
  11.                            "$_ `n"
  12.                         }
  13.                     }
  14. $emailFrom = "VM snapshot checker "
  15. $subject = "Powered On VMs with snapshots"
  16. $body = "$VM_list"
  17. $smtp = new-object Net.Mail.SmtpClient($smtpServer)
  18. if ($body -ne $null) { $smtp.Send($emailFrom, $emailTo, $subject, $body)}
  19. "ok"

Комментариев нет:

Отправить комментарий