Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $a = "<style>"
- $a = $a + "BODY{background-color:peachpuff;}"
- $a = $a + "TABLE{border-width: 1px;border-style: solid;border-color: black;border-collapse: collapse;}"
- $a = $a + "TH{border-width: 1px;padding: 1px;border-style: solid;border-color: black;background-color:thistle}"
- $a = $a + "TD{border-width: 1px;padding: 1px;border-style: solid;border-color: black;background-color:PaleGoldenrod}"
- $a = $a + "</style>"
- [array]$vcenter_srv = @("10.11.12.13","qwerty@outlook.com")
- [array]$allobj = @()
- [string]$Admin = "sudershan.bharti@gmail.com"
- [string]$vPass = "Passw0rd"
- $OutputPath="C:\Temp\ClusterBuildCompare"
- Remove-Item -Path ($OutputPath + "\*.*") -Confirm:$false -Force:$true -ErrorAction SilentlyContinue 2>&1 > $null
- $vcenter_srv | %{
- Connect-VIServer $_ -User $Admin -Password $vPass -ErrorAction Stop
- $i = 0
- $vC = $_
- $obj = New-Object -TypeName PSObject
- $Clusters = Get-Cluster
- Foreach ($Cluster in $Clusters){
- $props = @{
- "vCenter" = $vC;
- "Name"= $Cluster.Name;
- "Build#" = ($Cluster | Get-VMHost | Group-Object Build | ?{$_.Name -ne ''} | Select -ExpandProperty Name) -join " + ";
- "ESXiHost" = ($Cluster | Get-VMHost | Group-Object Build | ?{$_.Name -ne ''} | Select -ExpandProperty Count) -join " + "
- }
- $obj = New-Object -TypeName PSObject -Property $Props
- $props = ""
- $obj = $obj | Select-Object -Property "vCenter", "Name", "Build#", "ESXiHost"
- Write-Progress -Activity "Looking up Clusters" -Status "Current Cluster: $Cluster in $_" -PercentComplete ($i/$Clusters.Count*100)
- $i++
- $allobj += $obj
- }
- Disconnect-VIServer * -Confirm:$false
- }
- $allobj | Select-Object -Property * | Export-Csv -Path $OutputPath\ClusterBuildCompare.csv -NoTypeInformation
- $allobj | ConvertTo-Html -Head $a | Out-File $OutputPath\ClusterBuildCompare.html
- $emailto = "Sudershan.Bharti@gmail.com"
- $emailcc = "Sudershan.Bharti@gmail.com"
- $emailfrom = "VMHostBuildInfo@gmail.com"
- $smtpserver = "smtp.gmail.com"
- $vmbody = Get-Content $OutputPath\ClusterBuildCompare.html
- Send-mailmessage -to $emailto -cc $emailcc -from $emailfrom -subject "Cluster Build# Comparison" -body ($vmbody | out-string) -BodyAsHtml -SmtpServer $smtpserver
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement