PowerCli Script to send your Virtual Machine performance report to your email

PowerCli Script to send your Virtual Machine performance report to your email

 

Script Download >> REPORT_MULTI_performance

 

add-pssnapin VMware.VimAutomation.Core
$vCenter = “vc01.lab.local” #Server Vcenter
$VMs = “server1″,”server2″,”server3” #Servers list
$stats = @()
$date = get-date -f yyyy-MM-dd
$filename = “c:\Marcin_raporty\PERFORMANCE_REPORT_$date.csv” #Sciezka gdzie zostanie zapisany raport

# Zmienne do emaila
$SMTP = “smtp.lab.local”
$MyEmail = “vmlab@lab.local”
$To = “vmlab_Backup@lab.local”
$CC = “dg@lab.local”
$Subject = “Performance_$VMs_$date”
$Body = “Performance for $VMs $date”
$Attachment = $filename

Write-Host “podaczanie do servera $vCenter”
Connect-VIServer $vCenter
foreach($VM in $VMs)
{

$stats += Get-Stat -Entity ($VM) -start (get-date).AddDays(-7) -Finish (Get-Date) -MaxSamples 100000 -stat “cpu.usage.average”,”cpu.usagemhz.average”,”mem.usage.average”,”mem.consumed.average” -IntervalSecs 1800 |Sort-Object entity, Timestamp

}

#$stats | Export-Csv c:\Marcin_raporty\PERFORMANCE_REPORT_$date.csv

Write-Host “Generowanie Raportu”
$stats | Export-Csv $filename

 

Start-Sleep 2

Send-MailMessage -SmtpServer $SMTP -From $MyEmail -To $To , $CC -Subject $Subject -Body $Body -Attachments $Attachment
write-host “E-mail wyslano”

 

 

                                                                                                                     Please Subscribe

Loading

Leave a Reply

Your email address will not be published. Required fields are marked *