26 C
Dubai
Friday, March 29, 2024

VMWare Esxi Compliance Report

Checks for Esxi Settings and creates a Neat HTML page.

  • ipv6
  • ESXShell
  • SSH
  • SearchDomain
  • DomainName
  • NTPServer
  • SystemLogs
  • ScratchConfig
  • SuppressShellWarning

VMwareEsxiComplianceReport

Store your Credentials

$cred = Get-Credential

Connect to VCenter

Connect-VIServer -Server 10.10.10.100 -Protocol https -Credential $cred

image_thumb88_thumb

Save as .ps1 and run it.


<#

.Runs in VMware Vsphere PowerCLI 6.0 - PowerShell

.SYNOPSIS
.\VMwareEsxiComplianceReport.ps1 -

It displays Complete Exchange Environment Information in a modern HTML.

Checks for Esxi Settings and creates a Neat HTML page.
ipv6
ESXShell
SSH
SearchDomain
DomainName
NTPServer
SystemLogs
ScratchConfig
SuppressShellWarning

.Author
Written By: Satheshwaran Manoharan

Change Log
V1.0, 27/04/2016 - Initial version

#>
Write-Progress -Activity "Date" -status "Collecting Dates info"
$Date = Get-date -ErrorAction SilentlyContinue

# ----- Settings ----

#Should the Script Open the HTML File locally on Finishing the script - Say Yes - if you wish to

$Openhtmllocally = "Yes"

Write-Progress -Activity "Email Settings" -status "Storing Email Settings"
## ----- Email ----Fill in with your details
<#
$EmailTo = "administrator@dubai.com"
$EmailFrom = "administrator@dubai.com"
$EmailSubject = "Modern Exchange Environement Report $Date"
# Creating Anonymous Relay - <a href="https://www.azure365pro.com/how-to-configure-a-relay-connector-for-exchange-server-2013/">https://www.azure365pro.com/how-to-configure-a-relay-connector-for-exchange-server-2013/</a>
$SmtpServer = "10.128.57.55"
#>

#Enter Attachment Location.
$Attachment = "C:\temp\VMwareEsxiComplianceReport.htm"

# ----- Settings ----

#Collecting Environment Information
Write-Progress -Activity "VMHosts" -status "Collecting VMHosts info"
$VMHosts = Get-VMHost -ErrorAction SilentlyContinue
$VMHostsON = $VMHosts | Where-object{$_.powerstate -like "PoweredOn"}

Write-Progress -Activity "VMs" -status "Collecting Collecting VMs info"
$VMs = Get-VM -ErrorAction SilentlyContinue

Write-Progress -Activity "Datastores" -status "Collecting Databases info"
$Datastores = Get-Datastore -ErrorAction SilentlyContinue

Write-Progress -Activity "Clusters" -status "Collecting Clusters info"
$Clusters = Get-Cluster -ErrorAction SilentlyContinue

#Applying Initial CSS For the HTML
Write-Progress -Activity "VMwareEsxiComplianceReport" -status "Applying CSS"
$head = @"
<Title>Volume Report</Title>
<Style>
.CSSTableGenerator {
margin:0px;padding:0px;
width:100%;
box-shadow: 10px 10px 5px #888888;
border:1px solid #7aa3c1;

-moz-border-radius-bottomleft:0px;
-webkit-border-bottom-left-radius:0px;
border-bottom-left-radius:0px;

-moz-border-radius-bottomright:0px;
-webkit-border-bottom-right-radius:0px;
border-bottom-right-radius:0px;

-moz-border-radius-topright:0px;
-webkit-border-top-right-radius:0px;
border-top-right-radius:0px;

-moz-border-radius-topleft:0px;
-webkit-border-top-left-radius:0px;
border-top-left-radius:0px;
}.CSSTableGenerator table{
border-collapse: collapse;
border-spacing: 0;
width:100%;
height:100%;
margin:0px;padding:0px;
}.CSSTableGenerator tr:last-child td:last-child {
-moz-border-radius-bottomright:0px;
-webkit-border-bottom-right-radius:0px;
border-bottom-right-radius:0px;
}
.CSSTableGenerator table tr:first-child td:first-child {
-moz-border-radius-topleft:0px;
-webkit-border-top-left-radius:0px;
border-top-left-radius:0px;
}
.CSSTableGenerator table tr:first-child td:last-child {
-moz-border-radius-topright:0px;
-webkit-border-top-right-radius:0px;
border-top-right-radius:0px;
}.CSSTableGenerator tr:last-child td:first-child{
-moz-border-radius-bottomleft:0px;
-webkit-border-bottom-left-radius:0px;
border-bottom-left-radius:0px;
}.CSSTableGenerator tr:hover td{

}
.CSSTableGenerator tr:nth-child(odd){ background-color:#ffffff; }
.CSSTableGenerator tr:nth-child(even){ background-color:#ffffff; }
.CSSTableGenerator td{
vertical-align:middle;
border:1px solid #7aa3c1;
border-width:0px 1px 1px 0px;
text-align:center;
padding:8px;
font-size:10px;
font-family:Arial;
font-weight:normal;
color:#000000;
}.CSSTableGenerator tr:last-child td{
border-width:0px 1px 0px 0px;
}.CSSTableGenerator tr td:last-child{
border-width:0px 0px 1px 0px;
}.CSSTableGenerator tr:last-child td:last-child{
border-width:0px 0px 0px 0px;
}
.CSSTableGenerator tr:first-child td{
background:-o-linear-gradient(bottom, #0072c6 5%, #0072c6 100%);
background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #0072c6), color-stop(1, #0072c6) );
background:-moz-linear-gradient( center top, #0072c6 5%, #0072c6 100% );
filter:progid:DXImageTransform.Microsoft.gradient(startColorstr="#0072c6", endColorstr="#0072c6");
background: -o-linear-gradient(top,#0072c6,0072c6);
background-color:#0072c6;
border:0px solid #7aa3c1;
text-align:center;
border-width:0px 0px 1px 1px;
font-size:14px;
font-family:Trebuchet MS;
font-weight:bold;
color:#ffffff;
}
.CSSTableGenerator tr:first-child:hover td{
background:-o-linear-gradient(bottom, #0072c6 5%, #0072c6 100%);
background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #0072c6), color-stop(1, #0072c6) );
background:-moz-linear-gradient( center top, #0072c6 5%, #0072c6 100% );
filter:progid:DXImageTransform.Microsoft.gradient(startColorstr="#0072c6", endColorstr="#0072c6");
background: -o-linear-gradient(top,#0072c6,0072c6);
background-color:#0072c6;
}
.CSSTableGenerator tr:first-child td:first-child{
border-width:0px 0px 1px 0px;
}
.CSSTableGenerator tr:first-child td:last-child{
border-width:0px 0px 1px 1px;
}
</Style>
"@

#Create Tables in split so that users can remove or add tables easily.
$start = @"
<html><div class="CSSTableGenerator">
"@
Write-Progress -Activity "ModernExchangeEnvironmentReport" -status "Writing Enviroment Initial Info"
$Table1 =@"
<table>
<tr><td>No.VMHosts</td>
<td>No.VMs</td>
<td>No.Datastores</td>
<td>No.Clusters</td>
<td>Date</td>
</tr>
<tr><td>$($VMHosts.count)</td>
<td>$($VMs.count)</td>
<td>$($Datastores.count)</td>
<td>$($Clusters.count)</td>
<td>$($Date)</td>
</tr>
</table>
<table>
<tr><td>VMHostname</td>
<td>State</td>
<td>PowerState</td>
<td>Model</td>
<td>Version</td>
</tr>
"@
Write-Progress -Activity "VMHosts" -status "Writing Vmhosts info"
$Table2 =
foreach ($VMHost in ($VMHosts))
{"<tr><td>$($VMHost.name)</td>
<td>$($VMHost.connectionstate)</td>
<td>$($VMHost.PowerState)</td>
<td>$($VMHost.Model)</td>
<td>$($VMHost.ApiVersion)</td>
</tr>"}

$table2close = @"
</table>
"@
Write-Progress -Activity "AdvanceSettings" -status "Writing AdvanceSettings info"
$Table3 =@"
<table>
<tr><td>VMHostname</td>
<td>State</td>
<td>IPv6</td>
<td>ESXi Shell</td>
<td>SSH</td>
<td>Searchdomain</td>
<td>DomainName</td>
<td>NTPServer</td>
<td>SysLogs</td>
<td>SuppressShellWarning</td>
<td>ScratchConfig</td>
"@

$Table3data =
foreach ($VMHost in ($VMHostsON))
{"<tr><td>$($VMHost.name)</td>
<td>$($VMHost.connectionstate)</td>
<td>$(($VMHost | Get-VMHostNetwork).IPv6Enabled)</td>
<td>$(($VMHost | Get-VMHostService | Where-Object {$_.Key -eq "TSM"}).policy)</td>
<td>$(($VMHost | Get-VMHostService | Where-Object {$_.Key -eq "TSM-SSH"}).policy)</td>
<td>$(($VMHost | Get-VMHostNetwork).searchdomain)</td>
<td>$(($VMHost | Get-VMHostNetwork).domainname)</td>
<td>$(($VMHost | Get-VMHostNtpServer))</td>
<td>$(($VMHost | Get-AdvancedSetting syslog.Global.logdir).value)</td>
<td>$(($VMHost | Get-AdvancedSetting UserVars.SuppressShellWarning).value)</td>
<td>$(($VMHost | Get-AdvancedSetting -Name "ScratchConfig.ConfiguredScratchLocation").value)</td>
</tr>"}

$table3close = @"
</table>
"@
$complete = @"
</div></html>
"@
#Combining All Tables.

$alltables = "$start $Table1 $Table2 $table2close $Table3 $Table3data $table3close $complete"

$Combine = ConvertTo-Html -Head $head -Body $alltables

#Saving HTML File To the local C Drive - You can modify as per your wish.
$html += $Combine
$html > $Attachment

#open the HTML File Locally
If($Openhtmllocally -eq "yes")
{
Invoke-Item "$Attachment"
}
else
{
Write-Progress -Activity "Open HTML" -status "Settings - Do not Open"
}

<#
#Sending Email Message

$Disclaimer = "<font color=gray><div style=font-size:8pt;font-family:Calibri,sans-serif;>
The information contained in this e-mail and any files transmitted with it are confidential and may be privileged.   Access to this e-mail by anyone other than the intended is unauthorized. If you are not the intended recipient (or responsible for delivery of the message to such person), you may not use, copy, distribute or deliver to anyone this message (or any part of its contents) or take any action in reliance on it. In such case, you should destroy this message, and notify us immediately. If you have received this email in error, please notify us immediately by e-mail or telephone and delete the e-mail from any computer. If you or your employer does not consent to internet e-mail messages of this kind, please notify us immediately. All reasonable precautions have been taken to ensure no viruses are present in this e-mail. As our company cannot accept responsibility for any loss or damage arising from the use of this e-mail or attachments we recommend that you subject these to your virus checking procedures prior to use. The views, opinions, conclusions and other information expressed in this electronic mail are not given or endorsed by the company unless otherwise indicated by an authorized representative independent of this message."

Send-mailmessage -to $EmailTo -from $EmailFrom -subject $EmailSubject -SmtpServer $SmtpServer -Body $Disclaimer -BodyAsHtml -Attachments $Attachment -ErrorAction SilentlyContinue
#>

Satheshwaran Manoharan
Satheshwaran Manoharanhttps://www.azure365pro.com
Award-winning Technology Leader with a wealth of experience running large teams and diversified industry exposure in cloud computing. From shipping lines to rolling stocks.In-depth expertise in driving cloud adoption strategies and modernizing systems to cloud native. Specialized in Microsoft Cloud, DevOps, and Microsoft 365 Stack and conducted numerous successful projects worldwide. Also, Acting as a Technical Advisor for various start-ups.

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

× How can I help you?