Advertisement
Guest User

Untitled

a guest
Sep 15th, 2017
469
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.11 KB | None | 0 0
  1. $a = "<style>"
  2. $a = $a + "BODY{background-color:peachpuff;}"
  3. $a = $a + "TABLE{border-width: 1px;border-style: solid;border-color: black;border-collapse: collapse;}"
  4. $a = $a + "TH{border-width: 1px;padding: 1px;border-style: solid;border-color: black;background-color:thistle}"
  5. $a = $a + "TD{border-width: 1px;padding: 1px;border-style: solid;border-color: black;background-color:PaleGoldenrod}"
  6. $a = $a + "</style>"
  7.  
  8. [array]$vcenter_srv = @("10.11.12.13","qwerty@outlook.com")
  9. [array]$allobj = @()
  10. [string]$Admin = "sudershan.bharti@gmail.com"
  11. [string]$vPass = "Passw0rd"
  12. $OutputPath="C:\Temp\ClusterBuildCompare"
  13.  
  14. Remove-Item -Path ($OutputPath + "\*.*") -Confirm:$false -Force:$true -ErrorAction SilentlyContinue 2>&1 > $null
  15.  
  16. $vcenter_srv | %{
  17. Connect-VIServer $_ -User $Admin -Password $vPass -ErrorAction Stop
  18. $i = 0
  19. $vC = $_
  20. $obj = New-Object -TypeName PSObject
  21. $Clusters = Get-Cluster
  22. Foreach ($Cluster in $Clusters){
  23. $props = @{
  24. "vCenter" = $vC;
  25. "Name"= $Cluster.Name;
  26. "Build#" = ($Cluster | Get-VMHost | Group-Object Build | ?{$_.Name -ne ''} | Select -ExpandProperty Name) -join " + ";
  27. "ESXiHost" = ($Cluster | Get-VMHost | Group-Object Build | ?{$_.Name -ne ''} | Select -ExpandProperty Count) -join " + "
  28. }
  29. $obj = New-Object -TypeName PSObject -Property $Props
  30. $props = ""
  31. $obj = $obj | Select-Object -Property "vCenter", "Name", "Build#", "ESXiHost"
  32. Write-Progress -Activity "Looking up Clusters" -Status "Current Cluster: $Cluster in $_" -PercentComplete ($i/$Clusters.Count*100)
  33. $i++
  34. $allobj += $obj
  35. }
  36. Disconnect-VIServer * -Confirm:$false
  37. }
  38. $allobj | Select-Object -Property * | Export-Csv -Path $OutputPath\ClusterBuildCompare.csv -NoTypeInformation
  39. $allobj | ConvertTo-Html -Head $a | Out-File $OutputPath\ClusterBuildCompare.html
  40. $emailto = "Sudershan.Bharti@gmail.com"
  41. $emailcc = "Sudershan.Bharti@gmail.com"
  42. $emailfrom = "VMHostBuildInfo@gmail.com"
  43. $smtpserver = "smtp.gmail.com"
  44. $vmbody = Get-Content $OutputPath\ClusterBuildCompare.html
  45. 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