#convertto-html css
Explore tagged Tumblr posts
Text
Creating HTML report with CSS (Cascading Style Sheet) using Powershell
Creating HTML report with CSS (Cascading Style Sheet) using Powershell
All Tech/non Tech peoples loves a nice HTML report for reviewing. Creating these type of reports in PowerShell is very easy and simple. These type of nice HTML reports can be generate with the help ConvertTo-HTML cmdlet. Converts Microsoft .NET Framework objects into HTML that can be displayed in a Web browser. The ConvertTo-HTML does not create an actual file, just the HTML code.This means that…
View On WordPress
#com powershell#convertto-html css#Creating HTML report with CSS (Cascading Style Sheet) using Powershell#creating html reports in powershell#powershell convert from html#powershell convert xml to html#powershell convertto-html fragment#powershell convertto-html multiple tables#powershell html report generator#powershell html report template#thiyagu dotnet-helpers
0 notes
Text
New Post has been published on
New Post has been published on https://www.tayfundeger.com/powercli-ile-aylik-performans-raporu.html
PowerCli ile Aylık VM Performans Raporu
Merhaba,
PowerCli ile Aylık VM Performans Raporu isimli bu yazımda sizlere VMware ortamınızda bulunan virtual machine’lerin aylık performans raporlarının nasıl çekileceği hakkında bilgi vereceğim.
Daha önce Günlük ve Haftalık script’leri paylaşmıştım. Bu yazılarıma aşağıdaki linkten ulaşabilirsiniz.
PowerCli ile Günlük VM Performans Raporu
PowerCli ile Haftalık VM Performans Raporu
Aşağıda belirteceğim script sayesinde ortamınızda bulunan virtual machine’lerin aylık performans ortalamasını alabilirsiniz.
Bu script’i çalıştırdığınızda karşınıza yukarıdaki gibi bir html çıktısı gelecektir. Eğer script’de SMTP ayarlarını doğru bir şekilde yaparsanız size mail olarakta gelebilir. Script’i isterseniz Windows Task Scheduler’e tanımlayabilir, böylece istediğiniz zaman aralığında düzenli olarak çalışmasını sağlayabilirsiniz.
[php]
## VM Configuration Report ## ## Composed by Tayfun Deger## ## mailto:[email protected] ## https://www.tayfundeger.com## ########################################################################## # Style of the Report in Css $Css=”<style> body font-family: Verdana, sans-serif; font-size: 14px; color: #666666; background: #FEFEFE; #title color:#FF0000; font-size: 30px; font-weight: bold; padding-top:25px; margin-left:35px; height: 50px; #subtitle font-size: 11px; margin-left:35px; #main position:relative; padding-top:10px; padding-left:10px; padding-bottom:10px; padding-right:10px; #box1 position:absolute; background: #F8F8F8; border: 1px solid #DCDCDC; margin-left:10px; padding-top:10px; padding-left:10px; padding-bottom:10px; padding-right:10px; #boxheader font-family: Arial, sans-serif; padding: 5px 20px; position: relative; z-index: 20; display: block; height: 30px; color: #777; text-shadow: 1px 1px 1px rgba(255,255,255,0.8); line-height: 33px; font-size: 19px; background: #fff; background: -moz-linear-gradient(top, #ffffff 1%, #eaeaea 100%); background: -webkit-gradient(linear, left top, left bottom, color-stop(1%,#ffffff), color-stop(100%,#eaeaea)); background: -webkit-linear-gradient(top, #ffffff 1%,#eaeaea 100%); background: -o-linear-gradient(top, #ffffff 1%,#eaeaea 100%); background: -ms-linear-gradient(top, #ffffff 1%,#eaeaea 100%); background: linear-gradient(top, #ffffff 1%,#eaeaea 100%); filter: progid:DXImageTransform.Microsoft.gradient( startColorstr=’#ffffff’, endColorstr=’#eaeaea’,GradientType=0 ); box-shadow: 0px 0px 0px 1px rgba(155,155,155,0.3), 1px 0px 0px 0px rgba(255,255,255,0.9) inset, 0px 2px 2px rgba(0,0,0,0.1);
table width:100%; border-collapse:collapse; table td, table th border:1px solid #FA5858; padding:3px 7px 2px 7px; table th text-align:left; padding-top:5px; padding-bottom:4px; background-color:#FA5858; color:#fff; table tr.alt td color:#000; background-color:#F5A9A9; </style>” # End the Style. ######################################## HTML Markup for SYM############################# $PageBoxOpener=”<div id=’box1’>” $ReportVMs=”<div id=’boxheader’>Aylık Sanal Sunucuları Performans Raporu</div>” $Report=”<table><tr><th>VM Name</th><th>PowerState</th><th>vHardware</th><th>vCPU Count</th><th>vMtools version</th><th>vCPU </th><th>vMemory (MB)</th><th>Provisioned Disk Size(GB)</th><th>Used Disk Size (GB)</th><th>Guest OS</th><th>IP Address</th></tr>” $BoxContentOpener=”<div id=’boxcontent’>” $PageBoxCloser=”</div>” $br=”<br>” $ReportGetVmCluster=”<div id=’boxheader’></div>” ######################### End HTML Markup ############################################## ###### Import Required Modules & Connect vCenter Server with Credentials # Get-Module -Name VMware* -ListAvailable | Import-Module Import-Module VMware.VimAutomation.Core Add-PSSnapin VMware.VimAutomation.Core -ErrorAction SilentlyContinue Connect-VIServer VCENTER-IP -User VCENTER-USERNAME -Password VCENTER-PASSWORD ##### Ana kod ####### get-vm | select Name, PowerState, @l=”Total Cpu Amount”;e=$_.numcpu, @N=”CPU Monthly Average (%)”; E=[Math]::Round((($_ , @N=”CPU Monthly Peak (%)”; E= Get-Stat -Stat cpu.usage.average -Start (get-date).Addmonths(-1) -Finish (get-date).AddDays(-1) , @l=”Total Memory Amount (GB)”;e=$_.MemoryGB, @N=”Memory Monthly Average(%)”; E= Get-Stat -Stat mem.usage.average -Start (get-date).Addmonths(-1) -Finish (get-date).AddDays(-1) , @N=”Memory Monthly Peak(%)”; E= Measure-Object Value -Maximum).Maximum),2), @N=”Network Monthly Average(Kbps)”; E= Get-Stat -Stat net.usage.average -Start (get-date).Addmonths(-1) -Finish (get-date).AddDays(-1) , @N=”Network Monthly Peak(Kbps)”; E= Measure-Object Value -Maximum).Maximum),2), @N=”Disk Monthly Average(KBps)”; E= Get-Stat -Stat disk.usage.average -Start (get-date).Addmonths(-1) -Finish (get-date).AddDays(-1) , @N=”Disk Monthly Peak(KBps)”; E= Get-Stat -Stat disk.usage.average -Start (get-date).Addmonths(-1) -Finish (get-date).AddDays(-1) , @n=”TotalHDSizeGB”; e=(Get-HardDisk -VM $_ , @N=’Disk Partititons’;E= %” $($_.DiskPath) $([math]::Round($_.Capacity /1024MB)) GB”) -join ‘,’ | Sort-Object Name -Descending | ConvertTo-HTML -Title “Aylık VM Performans Raporu” -Head “<div id=’title’> Virtualization Management- Virtual Machine Performance Report</div>$br<div id=’subtitle’>Report Date $(Get-Date)</div>” -Body ” $Css $PageBoxOpener $ReportClusterStats $BoxContentOpener</table> $br $ReportGetVmCluster $BoxContentOpener $GetVmCluster $PageBoxCloser” | Out-File c:\monthly-Virtual_Machine_Performance_Report.html ##### Ana kod sonu ##### ########### Mailing Variables ######## ################################ $fromaddress = “[email protected]” $toaddress = “[email protected]” $CCaddress = “[email protected]” $Subject = “Monthly Virtual Machine Performance Report” $attachment = “c:\monthly-Virtual_Machine_Performance_Report.html” $smtpserver = “SMTP-IP-ADRESI” ############ Send E-mail ############################################ $message = new-object System.Net.Mail.MailMessage $message.From = $fromaddress $message.To.Add($toaddress) $message.CC.Add($CCaddress) $message.IsBodyHtml = $True $message.Subject = $Subject $attach = new-object Net.Mail.Attachment($attachment) $message.Attachments.Add($attach) $message.body = $body $smtp = new-object Net.Mail.SmtpClient($smtpserver) $smtp.Send($message) ######### Disconnect vCenter & Finish script ########################## Disconnect-VIServer localhost -Confirm:$False
exit
[/php]
0 notes
Text
New Post has been published on
New Post has been published on https://www.tayfundeger.com/powercli-ile-haftalik-vm-performans-raporu.html
PowerCli ile Haftalık VM Performans Raporu
Merhaba,
PowerCli ile Haftalık VM Performans Raporu isimli bu yazımda vCenter Server üzerinde bulunan virtual machine’lerin haftalık olarak raporlarını alabileceğiniz bir script paylaşacağım. Eğer bu script’in günlük performansını kullanmak istiyorsanız aşağıdaki link’i inceleyebilirsiniz.
PowerCli ile Günlük VM Performans Raporu
PowerCli ile Haftalık VM Performans Raporu
Haftalık performans raporu script’ini Windows task scheduler’a haftada 1 kez çalışacak şekilde tanımlayabilirsiniz. Böylece her hafta düzenli olarak performans raporları mail’inize gelecektir.
Aşağıda yer alan bazı bölümleri kendinize göre değiştirmeniz gerekmektedir.
[php]
## VM Configuration Report ## ## Composed by Tayfun Deger## ## mailto:[email protected] ## http://www.tayfundeger.com ## ########################################################################## # Style of the Report in Css $Css=”<style> body font-family: Verdana, sans-serif; font-size: 14px; color: #666666; background: #FEFEFE; #title color:#FF0000; font-size: 30px; font-weight: bold; padding-top:25px; margin-left:35px; height: 50px; #subtitle font-size: 11px; margin-left:35px; #main position:relative; padding-top:10px; padding-left:10px; padding-bottom:10px; padding-right:10px; #box1 position:absolute; background: #F8F8F8; border: 1px solid #DCDCDC; margin-left:10px; padding-top:10px; padding-left:10px; padding-bottom:10px; padding-right:10px; #boxheader font-family: Arial, sans-serif; padding: 5px 20px; position: relative; z-index: 20; display: block; height: 30px; color: #777; text-shadow: 1px 1px 1px rgba(255,255,255,0.8); line-height: 33px; font-size: 19px; background: #fff; background: -moz-linear-gradient(top, #ffffff 1%, #eaeaea 100%); background: -webkit-gradient(linear, left top, left bottom, color-stop(1%,#ffffff), color-stop(100%,#eaeaea)); background: -webkit-linear-gradient(top, #ffffff 1%,#eaeaea 100%); background: -o-linear-gradient(top, #ffffff 1%,#eaeaea 100%); background: -ms-linear-gradient(top, #ffffff 1%,#eaeaea 100%); background: linear-gradient(top, #ffffff 1%,#eaeaea 100%); filter: progid:DXImageTransform.Microsoft.gradient( startColorstr=’#ffffff’, endColorstr=’#eaeaea’,GradientType=0 ); box-shadow: 0px 0px 0px 1px rgba(155,155,155,0.3), 1px 0px 0px 0px rgba(255,255,255,0.9) inset, 0px 2px 2px rgba(0,0,0,0.1);
table width:100%; border-collapse:collapse; table td, table th border:1px solid #FA5858; padding:3px 7px 2px 7px; table th text-align:left; padding-top:5px; padding-bottom:4px; background-color:#FA5858; color:#fff; table tr.alt td color:#000; background-color:#F5A9A9; </style>” # End the Style. ######################################## HTML Markup ############################# $PageBoxOpener=”<div id=’box1’>” $ReportVMs=”<div id=’boxheader’>Haftalık Sanal Sunucuları Performans Raporu</div>” $Report=”<table><tr><th>VM Name</th><th>PowerState</th><th>vHardware</th><th>vCPU Count</th><th>vMTools version</th><th>vCPU </th><th>vMemory (MB)</th><th>Provisioned Disk Size(GB)</th><th>Used Disk Size (GB)</th><th>Guest OS</th><th>IP Address</th></tr>” $BoxContentOpener=”<div id=’boxcontent’>” $PageBoxCloser=”</div>” $br=”<br>” $ReportGetVmCluster=”<div id=’boxheader’></div>” ######################### End HTML Markup ############################################## ###### Import Required Modules & Connect vCenter Server with Credentials # Get-Module -Name VMware* -ListAvailable | Import-Module Import-Module VMware.VimAutomation.Core Add-PSSnapin VMware.VimAutomation.Core -ErrorAction SilentlyContinue Connect-VIServer VCENTER-IP -User VCENTER-USERNAME -Password VCENTER-PASS ##### Ana kod ####### get-vm | select Name, PowerState, @l=”Total Cpu Amount”;e=$_.numcpu, @N=”CPU Monthly Average (%)”; E= Get-Stat -Stat cpu.usage.average -Start (get-date).AddDays(-7) -Finish (get-date).AddDays(0) , @N=”CPU Monthly Peak (%)”; E=[Math]::Round((($_ , @l=”Total Memory Amount (GB)”;e=$_.MemoryGB, @N=”Memory Monthly Average(%)”; E=[Math]::Round((($_ , @N=”Memory Monthly Peak(%)”; E= Get-Stat -Stat mem.usage.average -Start (get-date).AddDays(-7) -Finish (get-date).AddDays(0) , @N=”Network Monthly Average(Kbps)”; E=[Math]::Round((($_ , @N=”Network Monthly Peak(Kbps)”; E= Get-Stat -Stat net.usage.average -Start (get-date).AddDays(-7) -Finish (get-date).AddDays(0) , @N=”Disk Monthly Average(KBps)”; E=[Math]::Round((($_ , @N=”Disk Monthly Peak(KBps)”; E= Get-Stat -Stat disk.usage.average -Start (get-date).AddDays(-7) -Finish (get-date).AddDays(0) , @n=”TotalHDSizeGB”; e= Measure-Object -Sum CapacityGB).Sum, @N=’Disk Partititons’;E=((get-vm $_).extensiondata.Guest.Disk | Sort-Object Name -Descending | ConvertTo-HTML -Title “VM Performans Raporu” -Head “<div id=’title’>Haftalık – Virtualization Management- Virtual Machine Performance Report</div>$br<div id=’subtitle’>Report Date $(Get-Date)</div>” -Body ” $Css $PageBoxOpener $ReportClusterStats $BoxContentOpener</table> $br $ReportGetVmCluster $BoxContentOpener $GetVmCluster $PageBoxCloser” | Out-File c:\weekly-Virtual_Machine_Performance_Report.html ##### Ana kod sonu ##### ########### Mailing Variables ######## ################################ $fromaddress = “[email protected]” $toaddress = “[email protected]” $CCaddress = “[email protected]” $Subject = “Weekly Virtual Machine Performance Report” $attachment = “c:\weekly-Virtual_Machine_Performance_Report.html” $smtpserver = “SMTP-IP” ############ Send E-mail ############################################ $message = new-object System.Net.Mail.MailMessage $message.From = $fromaddress $message.To.Add($toaddress) $message.CC.Add($CCaddress) $message.IsBodyHtml = $True $message.Subject = $Subject $attach = new-object Net.Mail.Attachment($attachment) $message.Attachments.Add($attach) $message.body = $body $smtp = new-object Net.Mail.SmtpClient($smtpserver) $smtp.Send($message) ######### Disconnect vCenter & Finish script ########################## Disconnect-VIServer localhost -Confirm:$False
exit
[/php]
Umarım faydalı olmuştur.
İyi çalışmalar.
0 notes
Text
New Post has been published on
New Post has been published on https://www.tayfundeger.com/powercli-ile-gunluk-vm-performans-raporu.html
PowerCli ile Günlük VM Performans Raporu
Merhaba,
PowerCli ile Günlük VM Performans Raporu isimli bu yazımda VMware vCenter Server üzerinde bulunan virtual machine’lerin günlük CPU, Memory, Disk ve Network kullanım oranlarını çekebilirsiniz.
Aşağıda belirteceğim script sayesinde günlük kulanım oranlarını çekebilir ve bunları mail ile gönderebilirsiniz. Hatta isterseniz, Windows task scheduler üzerinde tanımlama yapıp günlük düzenli olarak çalışmasını sağlayabilirsiniz.
PowerCli ile Günlük VM Performans Raporu
Bu script ile aşağıdaki verilerin günlük ortalamasını alabilirsiniz.
CPU
Memory
Network
Disk
Toplam disk
Free space
Script’i aşağıda görebilirsiniz, kendinize göre düzenlemeniz gerekmektedir.
[php]
## VM Configuration Report ## ## Composed by Tayfun Değer## ## mailto:[email protected] ## https://www.tayfundeger.com ## ########################################################################## # Style of the Report in Css $Css=”<style> body font-family: Verdana, sans-serif; font-size: 14px; color: #666666; background: #FEFEFE; #title color:#FF0000; font-size: 30px; font-weight: bold; padding-top:25px; margin-left:35px; height: 50px; #subtitle font-size: 11px; margin-left:35px; #main position:relative; padding-top:10px; padding-left:10px; padding-bottom:10px; padding-right:10px; #box1 position:absolute; background: #F8F8F8; border: 1px solid #DCDCDC; margin-left:10px; padding-top:10px; padding-left:10px; padding-bottom:10px; padding-right:10px; #boxheader font-family: Arial, sans-serif; padding: 5px 20px; position: relative; z-index: 20; display: block; height: 30px; color: #777; text-shadow: 1px 1px 1px rgba(255,255,255,0.8); line-height: 33px; font-size: 19px; background: #fff; background: -moz-linear-gradient(top, #ffffff 1%, #eaeaea 100%); background: -webkit-gradient(linear, left top, left bottom, color-stop(1%,#ffffff), color-stop(100%,#eaeaea)); background: -webkit-linear-gradient(top, #ffffff 1%,#eaeaea 100%); background: -o-linear-gradient(top, #ffffff 1%,#eaeaea 100%); background: -ms-linear-gradient(top, #ffffff 1%,#eaeaea 100%); background: linear-gradient(top, #ffffff 1%,#eaeaea 100%); filter: progid:DXImageTransform.Microsoft.gradient( startColorstr=’#ffffff’, endColorstr=’#eaeaea’,GradientType=0 ); box-shadow: 0px 0px 0px 1px rgba(155,155,155,0.3), 1px 0px 0px 0px rgba(255,255,255,0.9) inset, 0px 2px 2px rgba(0,0,0,0.1);
table width:100%; border-collapse:collapse; table td, table th border:1px solid #FA5858; padding:3px 7px 2px 7px; table th text-align:left; padding-top:5px; padding-bottom:4px; background-color:#FA5858; color:#fff; table tr.alt td color:#000; background-color:#F5A9A9; </style>” # End the Style. ######################################## HTML Markup for SYM############################# $PageBoxOpener=”<div id=’box1’>” $ReportVMs=”<div id=’boxheader’>Günlük Sanal Sunucuları Performans Raporu</div>” $Report=”<table><tr><th>VM Name</th><th>PowerState</th><th>vHardware</th><th>vCPU Count</th><th>vMTools version</th><th>vCPU </th><th>vMemory (MB)</th><th>Provisioned Disk Size(GB)</th><th>Used Disk Size (GB)</th><th>Guest OS</th><th>IP Address</th></tr>” $BoxContentOpener=”<div id=’boxcontent’>” $PageBoxCloser=”</div>” $br=”<br>” $ReportGetVmCluster=”<div id=’boxheader’></div>” ######################### End HTML Markup ############################################## ###### Import Required Modules & Connect vCenter Server with Credentials # Get-Module -Name VMware* -ListAvailable | Import-Module Import-Module VMware.VimAutomation.Core Add-PSSnapin VMware.VimAutomation.Core -ErrorAction SilentlyContinue Connect-VIServer VCENTER-IP-ADRESI -User VCENTER-USERNAME -Password VCENTER-PASS ##### Ana kod ####### get-vm | select Name, PowerState, @l=”Total Cpu Amount”;e=$_.numcpu, @N=”CPU Daily Average (%)”; E= Measure-Object Value -Average).Average),2), @N=”CPU Daily Peak (%)”; E= Measure-Object Value -Maximum).Maximum),2), @l=”Total Memory Amount (GB)”;e=$_.MemoryGB, @N=”Memory Daily Average(%)”; E= Get-Stat -Stat mem.usage.average -Start (get-date).AddDays(-1) -Finish (get-date).AddDays(0) , @N=”Memory Daily Peak(%)”; E=[Math]::Round((($_ , @N=”Network Daily Average(Kbps)”; E= Get-Stat -Stat net.usage.average -Start (get-date).AddDays(-1) -Finish (get-date).AddDays(0) , @N=”Network Daily Peak(Kbps)”; E=[Math]::Round((($_ , @N=”Disk Daily Average(KBps)”; E= Get-Stat -Stat disk.usage.average -Start (get-date).AddDays(-1) -Finish (get-date).AddDays(0) , @N=”Disk Daily Peak(KBps)”; E= Get-Stat -Stat disk.usage.average -Start (get-date).AddDays(-1) -Finish (get-date).AddDays(0) , @n=”TotalHDSizeGB”; e= Measure-Object -Sum CapacityGB).Sum, @N=’Disk Partititons’;E=((get-vm $_).extensiondata.Guest.Disk | Sort-Object Name -Descending | ConvertTo-HTML -Title “Gunluk VM Performans Raporu” -Head “<div id=’title’>Virtualization Management- Daily Virtual Machine Performance Report</div>$br<div id=’subtitle’>Report Date $(Get-Date)</div>” -Body ” $Css $PageBoxOpener $ReportClusterStats $BoxContentOpener</table> $br $ReportGetVmCluster $BoxContentOpener $GetVmCluster $PageBoxCloser” | Out-File c:\daily-Virtualization_Management-Virtual_Machine_Performance_Report.html ##### Ana kod sonu ##### ########### Mailing Variables ######## ################################ $fromaddress = “[email protected]” $toaddress = “[email protected]” # $CCaddress = “” $Subject = “Daily Virtualization Management – Daily Virtual Machine Performance Report” $attachment = “c:\Daily-Virtualization_Management-Virtual_Machine_Performance_Report.html” $smtpserver = “SMTP-IP-ADRESI” ############ Send E-mail ############################################ $message = new-object System.Net.Mail.MailMessage $message.From = $fromaddress $message.To.Add($toaddress) # $message.CC.Add($CCaddress) $message.IsBodyHtml = $True $message.Subject = $Subject $attach = new-object Net.Mail.Attachment($attachment) $message.Attachments.Add($attach) $message.body = $body $smtp = new-object Net.Mail.SmtpClient($smtpserver) $smtp.Send($message) ######### Disconnect vCenter & Finish script ########################## Disconnect-VIServer localhost -Confirm:$False
exit
[/php]
Umarım faydalı olmuştur.
İyi çalışmalar.
0 notes
Text
New Post has been published on
New Post has been published on https://www.tayfundeger.com/powercli-ile-datastore-kullanim-orani.html
PowerCli ile Datastore Kullanım Oranı
Merhaba,
PowerCli ile Datastore Kullanım Oranı isimli bu yazımda vCenter Server üzerinde bulunan datastore’larınızı günlük raporlayabilir ve doluluk oranlarını takip edebilirsiniz.
PowerCli ile Datastore Kullanım Oranı
Aşağıdaki script sayesinde vCenter Server üzerinde bulunan datastore’ların kapasite oranlarını ve datastore’ların virtual machine’e göre dağılımını görebilirsiniz.
Bu script ile aşağıdaki verileri çekmiş olursunuz.
Datastore name
FreespaceGB
CapacityGB
Freespace%
Provisioned VM’s Size(GB)
Virtual machine
Ayrıca bu verileri günlük olarak mail attırabilirsiniz. Aşağıdaki script’i kendinize göre düzenlemeniz gerekmektedir.
[php]
## DATASTORE PROVISONING REPORT ## ## Composed by Tayfun Değer## ## mailto:[email protected] ## https://www.tayfundeger.com ## ########################################################################## # Style of the Report in Css $Css=”<style> body font-family: Verdana, sans-serif; font-size: 14px; color: #666666; background: #FEFEFE; #title color:#FF0000; font-size: 30px; font-weight: bold; padding-top:25px; margin-left:35px; height: 50px; #subtitle font-size: 11px; margin-left:35px; #main position:relative; padding-top:10px; padding-left:10px; padding-bottom:10px; padding-right:10px; #box1 position:absolute; background: #F8F8F8; border: 1px solid #DCDCDC; margin-left:10px; padding-top:10px; padding-left:10px; padding-bottom:10px; padding-right:10px; #boxheader font-family: Arial, sans-serif; padding: 5px 20px; position: relative; z-index: 20; display: block; height: 30px; color: #777; text-shadow: 1px 1px 1px rgba(255,255,255,0.8); line-height: 33px; font-size: 19px; background: #fff; background: -moz-linear-gradient(top, #ffffff 1%, #eaeaea 100%); background: -webkit-gradient(linear, left top, left bottom, color-stop(1%,#ffffff), color-stop(100%,#eaeaea)); background: -webkit-linear-gradient(top, #ffffff 1%,#eaeaea 100%); background: -o-linear-gradient(top, #ffffff 1%,#eaeaea 100%); background: -ms-linear-gradient(top, #ffffff 1%,#eaeaea 100%); background: linear-gradient(top, #ffffff 1%,#eaeaea 100%); filter: progid:DXImageTransform.Microsoft.gradient( startColorstr=’#ffffff’, endColorstr=’#eaeaea’,GradientType=0 ); box-shadow: 0px 0px 0px 1px rgba(155,155,155,0.3), 1px 0px 0px 0px rgba(255,255,255,0.9) inset, 0px 2px 2px rgba(0,0,0,0.1);
table width:100%; border-collapse:collapse; table td, table th border:1px solid #FA5858; padding:3px 7px 2px 7px; table th text-align:left; padding-top:5px; padding-bottom:4px; background-color:#FA5858; color:#fff; table tr.alt td color:#000; background-color:#F5A9A9; </style>” # End the Style. ######################################## HTML Markup ################################### $PageBoxOpener=”<div id=’box1’>” $ReportVMs=”<div id=’boxheader’>Datastore Raporu</div>” $Report=”<table><tr><th>VM Name</th><th>PowerState</th><th>vHardware</th><th>vCPU Count</th><th>vMTools version</th><th>vCPU </th><th>vMemory (MB)</th><th>Provisioned Disk Size(GB)</th><th>Used Disk Size (GB)</th><th>Guest OS</th><th>IP Address</th></tr>” $BoxContentOpener=”<div id=’boxcontent’>” $PageBoxCloser=”</div>” $br=”<br>” $ReportGetVmCluster=”<div id=’boxheader’></div>” ######################### End HTML Markup ############################################## ############ Powershel’e gerekli Vmware Modullerini yukle & vCenter’a baglan ########## Get-Module -Name VMware* -ListAvailable | Import-Module Import-Module VMware.VimAutomation.Core Add-PSSnapin VMware.VimAutomation.Core -ErrorAction SilentlyContinue Connect-VIServer VCENTER-IP -User USER-YAZIN -Password PASSWORD-YAZIN ########### Ana kod #################################################################### get-datastore | select-object name, @Label=”FreespaceGB”;E=“0:n2” -f ($_.FreespaceGB), CapacityGB, @N=’Freespace%’;E=[math]::Round($_.FreespaceGB/$_.CapacityGB*100,1), @Label=”Provisioned VM’s Size(GB)”;E=“0:n2” -f ($_.CapacityGB – $_.FreespaceGB +($_.extensiondata.summary.uncommitted/1GB)), @N=’VM’;E=$_.ExtensionData.VM.Count | sort name | ConvertTo-HTML -Title “Virtualization Management – Datastore Provisioning Report” -Head “<div id=’title’> Virtualization Management – Datastore Provisioning Report</div>$br<div id=’subtitle’>Report Date $(Get-Date)</div>” -Body ” $Css $PageBoxOpener $ReportClusterStats $BoxContentOpener</table> $br $ReportGetVmCluster $BoxContentOpener $GetVmCluster $PageBoxCloser” | Out-File c:\datastores.html ########### Mail Degiskenleri ########################################################## $fromaddress = “[email protected]” $toaddress = “[email protected]” $CCaddress = “[email protected]” $Subject = “Virtualization Management – Datastore Provisioning Report” $body = “Datastorelarinin kapasite durumlari ekteki gibidir.” $attachment = “c:\datastores.html” $smtpserver = “SMTP-IP-ADRESİ” ############ E-mail Gonder ############################################################ $message = new-object System.Net.Mail.MailMessage $message.From = $fromaddress $message.To.Add($toaddress) $message.CC.Add($CCaddress) $message.IsBodyHtml = $True $message.Subject = $Subject $attach = new-object Net.Mail.Attachment($attachment) $message.Attachments.Add($attach) $message.body = $body $smtp = new-object Net.Mail.SmtpClient($smtpserver) $smtp.Send($message) ######### Disconnect vCenter & Finish script ########################################### Disconnect-VIServer localhost -Confirm:$False
exit
[/php]
0 notes