add-pssnapin VMware.VimAutomation.Core $smtpServer = "SMTP Server" $MailFrom = "From EMail ID" $mailto = Get-Content -Path C:\report\email_id.txt # mention email ID in "email_id.txt" to whom you want to send email. $input1=Get-Content -Path C:\report\vc_list.txt # mention vcenter name where you want to check resources. foreach($vc in $input1) { $file="C:\report\$($vc).html" # output of the report which will be send by email. if ( [System.IO.File]::Exists($file) ) { remove-item -force $file } Connect-VIServer $VC $a = "" ConvertTo-HTML -body "$($vc):Resource Pool Available Reservation."|out-file C:\pscripts\Gautham -Test\respool\$($vc).html -append foreach($clus in Get-Cluster){ Get-ResourcePool -Location $clus| Where-Object {$_.Name -eq "Serverprovisioning"} | Select @{N="Cluster";E={$clus.Name}},Name, @{N="Available Reservation MB";E={$_.Extensiondata.Runtime.Memory.UnreservedForPool/1MB}}|ConvertTo-HTML -head $a|out-file C:\pscripts\Gautham -Test\respool\$($vc).html -append } ConvertTo-HTML -body "$($vc):Over Provisioned DataStores."|out-file C:\pscripts\Gautham -Test\respool\$($vc).html -append Get-View -ViewType Datastore | Where-Object {$_.Name -notmatch "pag"} | ` Select-Object -Property Name, @{N="FreeSpaceGB";E={[Math]::Round($_.Summary.FreeSpace/1GB,0)}}, @{N="CapacityGB"; E={[Math]::Round($_.Summary.Capacity/1GB,0)}}, @{N="ProvisionedSpaceGB";E={[Math]::Round(($_.Summary.Capacity - $_.Summary.FreeSpace + $_.Summary.Uncommitted)/1GB,0)}}, @{N="OverProvisionedDS";E={([Math]::Round($_.Summary.Capacity/1GB,0)) - ([Math]::Round(($_.Summary.Capacity - $_.Summary.FreeSpace + $_.Summary.Uncommitted)/1GB,0))}}| ` Sort-Object -Property OverProvisionedDS | where {$_.OverProvisionedDS -match "-"} | Select-Object Name,FreeSpaceGB,CapacityGB,ProvisionedSpaceGB | ConvertTo-HTML -head $a |` out-file C:\report\$($vc).html -append ConvertTo-HTML -body "$($vc):Datastores < 1000 GB Free."|out-file C:\pscripts\Gautham -Test\respool\$($vc).html -append Get-View -ViewType Datastore | Where-Object {$_.Name -notmatch "pag"} | ` Select-Object -Property Name, @{N="FreeSpaceGB";E={[Math]::Round($_.Summary.FreeSpace/1GB,0)}}|` Sort-Object -Property FreeSpaceGB| where {$_.FreeSpaceGB -le 1000} | Select-Object Name,FreeSpaceGB | ConvertTo-HTML -head $a |` out-file C:\report\$($vc).html -append #$hr1="