Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Connect to Exchange
- . 'C:\Program Files\Microsoft\Exchange Server\V15\bin\RemoteExchange.ps1'
- Connect-ExchangeServer -auto
- clear
- $today = Get-Date -Format yyyy_MM_dd
- #Path to store the rport
- $filepath = "\\server\reports\$today`_Indexing.html"
- #Get DB info
- $dbstatus = Get-MailboxDatabaseCopyStatus
- #Start of the HTML file
- $html_header = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <style>
- table, th, td {
- border: 2px solid black;
- border-collapse: collapse;
- }
- th, td {
- padding: 10px;
- }
- </style>
- <title>HTML TABLE</title>
- </head><body>
- <table>
- <thead><tr><th>Name</th><th>Status</th><th>Indexing</th><th>Available Space</th><th>Free Disk Percent</th><th>Disk Free Space</th><th>Total Space</th><th>Volume</th><th>Disk Name</th></tr></thead>
- <tbody>'
- #Color code for easy to read informations
- $enabled= 'background-color:#00FF00'
- $warning = 'background-color:#FF0000'
- $info = 'background-color:#FFFF00'
- #Generate table row for each DB
- $body = ""
- $dbstatus | % {
- $space = Get-MailboxDatabase -Status $_.DatabaseName | select -ExpandProperty AvailableNewMailboxSpace
- $space_to_string = $space.ToSTring().Split('(')[0]
- #Warning Treshold : 20GB
- if($space.ToGB() -lt 20){
- $available_space = "<td style=`"$disable`">$space</td>"
- }
- #Notification treshold : 100GB
- elseif($space.ToGB() -lt 100){
- $available_space = "<td style=`"$info`">$space</td>"
- }
- else{
- $available_space = "<td>$space</td>"
- }
- #Check if DB status is Healthy
- if($_.ContentIndexState -like "Healthy"){
- $Indexing= "<td style=`"$enabled`">$($_.ContentIndexState)</td>"
- }
- else{
- $Indexing= "<td style=`"$warning`">$($_.ContentIndexState)</td>"
- }
- #Check DB free space
- #Warning Treshold : 1%
- if($_.DiskFreeSpacePercent -le 1){
- $FreePercent= "<td style=`"$warning`">$($_.DiskFreeSpacePercent)</td>"
- $free_space = $_.DiskFreeSpace.ToString().Split('(')[0]
- $FreeSpace= "<td style=`"$warning`">$free_space</td>"
- }
- else{
- $FreePercent= "<td style=`"$enabled`">$($_.DiskFreeSpacePercent)</td>"
- $free_space = $_.DiskFreeSpace.ToString().Split('(')[0]
- $FreeSpace= "<td style=`"$enabled`">$free_space</td>"
- }
- $ex_name = $_.Name.Split('\')[0]
- $name = "<tr><td>$ex_name</td>"
- $Copy= "<td>$($_.Status)</td>"
- $total_space = $_.DiskTotalSpace.ToString().Split('(')[0]
- $TotalSpace= "<td>$total_space</td>"
- $DBMount = "<td>$($_.DatabaseVolumeMountPoint)</td>"
- $db_name = $_.DatabaseVolumeName.split("{}")[1]
- $DBName= "<td>$db_name</td></tr>`n"
- $body+=$name+$Copy+$Indexing+$available_space+$FreePercent+$FreeSpace+$TotalSpace+$DBMount+$DBName
- }
- #End of HTML file
- $eof = "</tbody></table>
- </body></html>"
- $body += $eof
- #Concatenate the full HTML file
- $html_file = $html_header + $body
- $html_file | Out-File -FilePath $filepath
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement