HA

HA


###########################vCenter Server Snapshots Report #################################
############################## Created By Shobhit Mathur ###################################
############################## MAR - Modify As Required ####################################

$VIServers= "xxx"   ###MAR###
$reportFile = Get-Date -UFormat "E:\Sho\Reports\$VIServers-Snapshot_Report-%Y-%b-%d @ %I-%M%p.html"  ###MAR###
$today = get-Date

$Sho1=@"
<style>
TABLE {border-width: 1px;border-style: solid;border-color: black;border-collapse: collapse;Font-Size: 8pt;Font-Family: Tahoma, sans-serif;}
TH {border-width: 1px;padding: 3px;border-style: solid;border-color: black;background-color: #bc64ed;}
TD {border-width: 1px;padding: 3px;border-style: solid;border-color: black;}
</style>
"@

If (-not (Get-PSSnapin VMware.VimAutomation.Core))
{  Try { Add-PSSnapin VMware.VimAutomation.Core -ErrorAction Stop }
   Catch { Write-Host "Unable to load PowerCLI, is it installed?" -ForegroundColor Red; Break }
}
 Add-PSsnapin VMware.VimAutomation.Core -ErrorAction SilentlyContinue
foreach($viserver in $VIServers)
{
Connect-VIServer $VIServers -User xxx -Password xxx ###MAR###
}

$Sho1 += Get-Cluster "*"| Select-Object @{n="Cluster";e={$_.name}},@{n="Hosts";e={($_ | get-vmhost).count}},HAEnabled,
@{N=“Cpu %”; E={$_.ExtensionData.Configuration.DasConfig.AdmissionControlPolicy.CpuFailoverResourcesPercent}},
@{N=“Memory %”; E={$_.ExtensionData.Configuration.DasConfig.AdmissionControlPolicy.MemoryFailoverResourcesPercent}}, DRSEnabled | ConvertTo-Html -Fragment

Disconnect-VIServer $VIServers -Force -Confirm:$false


##############################################################################

$VIServers= "xxx"   ###MAR###
$reportFile = Get-Date -UFormat "E:\Sho\Reports\$VIServers-Snapshot_Report-%Y-%b-%d @ %I-%M%p.html"  ###MAR###
$today = get-Date

$Sho2=@"
<style>
TABLE {border-width: 1px;border-style: solid;border-color: black;border-collapse: collapse;Font-Size: 8pt;Font-Family: Tahoma, sans-serif;}
TH {border-width: 1px;padding: 3px;border-style: solid;border-color: black;background-color: #bc64ed;}
TD {border-width: 1px;padding: 3px;border-style: solid;border-color: black;}
</style>
"@

If (-not (Get-PSSnapin VMware.VimAutomation.Core))
{  Try { Add-PSSnapin VMware.VimAutomation.Core -ErrorAction Stop }
   Catch { Write-Host "Unable to load PowerCLI, is it installed?" -ForegroundColor Red; Break }
}
 Add-PSsnapin VMware.VimAutomation.Core -ErrorAction SilentlyContinue
foreach($viserver in $VIServers)
{
Connect-VIServer $VIServers -User xxx -Password xxx ###MAR###
}

$Sho2 += Get-Cluster "*"| Select-Object @{n="Cluster";e={$_.name}},@{n="Hosts";e={($_ | get-vmhost).count}},HAEnabled,
@{N=“Cpu %”; E={$_.ExtensionData.Configuration.DasConfig.AdmissionControlPolicy.CpuFailoverResourcesPercent}},
@{N=“Memory %”; E={$_.ExtensionData.Configuration.DasConfig.AdmissionControlPolicy.MemoryFailoverResourcesPercent}}, DRSEnabled | ConvertTo-Html -Fragment


$From = "xxx"   ###MAR###
$To = "xxx"   ###MAR###
$Cc = "xxx"   ###MAR###
$BCC = "xxx"   ###MAR###
$Subject = "HA Report of xxx & xxx" ###MAR###
$Body1 = "<p><h4>
HA Report of xxx as on $today.<br>
</h4></p>" #| Set-AlternatingRows -CSSEvenClass even -CSSOddClass odd

$Body3 = "<p><h4><br>
HA Report of xxx as on $today.<br> ###MAR###
</h4></p>" #| Set-AlternatingRows -CSSEvenClass even -CSSOddClass odd

$Body2 = "<p> <br><br>This is script generated report, hence for any discrapancies please contact 'xxx'.<br><br> ###MAR###
Best Regards<br>
Sho</p><br>" #| Set-AlternatingRows -CSSEvenClass even -CSSOddClass odd

$HTMLBody = $Body1 + $Sho2 +$Body3 +$Sho1 + $Body2
$SMTPServer = "xxx" ###MAR###
$SMTPPort = "25" ###MAR###

Send-MailMessage -From $From -to $To -cc $Cc -Bcc $BCC -Subject $Subject -BodyAsHTML -body $HTMLBody -SmtpServer $SMTPServer

Disconnect-VIServer $VIServers -Force -Confirm:$false


No comments:

Post a Comment