2
0

v1.1 added admin receivers and if statements for table creation

This commit is contained in:
2024-07-24 09:36:16 +02:00
parent 0ba5d9c93f
commit b07effeed5

View File

@@ -12,7 +12,6 @@
.NOTES .NOTES
This script is intended for use in a test or production environment. Make sure to test the script in a non-production environment before running it in production. This script is intended for use in a test or production environment. Make sure to test the script in a non-production environment before running it in production.
Author: D.de Kooker - info@dcomputers.nl Author: D.de Kooker - info@dcomputers.nl
Version: 1.0
DISCLAIMER: Use scripts at your own risk, if there is anything I can help you with I will try but I do not take responsibility for the way that anyone else uses my scripts. DISCLAIMER: Use scripts at your own risk, if there is anything I can help you with I will try but I do not take responsibility for the way that anyone else uses my scripts.
Sharing is caring. Share your knowledge with the world so that everybody can learn from it. Sharing is caring. Share your knowledge with the world so that everybody can learn from it.
@@ -31,7 +30,7 @@
#region Global script settings and variables #region Global script settings and variables
#General #General
$Version = "v1.0" $Version = "v1.1"
$logfilelocation = "$($MyInvocation.MyCommand.Path | Split-Path -Parent)\Logs" $logfilelocation = "$($MyInvocation.MyCommand.Path | Split-Path -Parent)\Logs"
$logfilename = "$(Get-Date -Format yyyyMMddHHmmss).log" $logfilename = "$(Get-Date -Format yyyyMMddHHmmss).log"
$summaryfilename = "$(Get-Date -Format yyyyMMddHHmmss)-Summary.txt" $summaryfilename = "$(Get-Date -Format yyyyMMddHHmmss)-Summary.txt"
@@ -44,6 +43,7 @@
$STR_EmailSubject= "Hyper-V Status Report - $(Get-Date -Format "dd-MM-yyyy")" $STR_EmailSubject= "Hyper-V Status Report - $(Get-Date -Format "dd-MM-yyyy")"
$STR_SMTPFromaddress = "ICT Servicedesk <servicedesk@contoso.com>" $STR_SMTPFromaddress = "ICT Servicedesk <servicedesk@contoso.com>"
$STR_Receivers = "servicedesk@contoso.com,systemengineer1@contoso.com" #List of commaseperated emailaddresses $STR_Receivers = "servicedesk@contoso.com,systemengineer1@contoso.com" #List of commaseperated emailaddresses
$STR_AdminReceivers = "servicedesk@contoso.com,systemengineer1@contoso.com" #list of additional emailaddresses that receive Warning and Error mails only
#endregion #endregion
#region functions #region functions
@@ -285,6 +285,7 @@
$htmlReport += "</table>" $htmlReport += "</table>"
#Generate VM Replication Health table #Generate VM Replication Health table
if ($VMreplinfo | Where-Object {$_.HVServer -eq $hvserver}) {
$htmlReport += @" $htmlReport += @"
<h3>Server: $hvserver - VM Replication Health</h3> <h3>Server: $hvserver - VM Replication Health</h3>
<table border='1'> <table border='1'>
@@ -299,6 +300,7 @@
<th>Relation</th> <th>Relation</th>
</tr> </tr>
"@ "@
foreach ($vm in ($VMreplinfo | Where-Object {$_.HVServer -eq $hvserver})) { foreach ($vm in ($VMreplinfo | Where-Object {$_.HVServer -eq $hvserver})) {
$htmlReport += @" $htmlReport += @"
@@ -319,8 +321,10 @@
"@ "@
} }
$htmlReport += "</table>" $htmlReport += "</table>"
}
#Generate VM Metric details table #Generate VM Metric details table
if ($VMmetricinfo | Where-Object {$_.HVServer -eq $hvserver}) {
$htmlReport += @" $htmlReport += @"
<h3>Server: $hvserver - VM Metric details</h3> <h3>Server: $hvserver - VM Metric details</h3>
<table border='1'> <table border='1'>
@@ -354,6 +358,7 @@
} }
$htmlReport += "</table>" $htmlReport += "</table>"
} }
}
$htmlReport += @" $htmlReport += @"
<p><i>This is an automated report.</i></p> <p><i>This is an automated report.</i></p>
</body> </body>
@@ -372,5 +377,9 @@
else { else {
$subject = "$STR_EmailSubject" $subject = "$STR_EmailSubject"
} }
SendMailv2 -To $STR_Receivers -Subject $subject -Body $htmlReport SendMailv2 -To $STR_Receivers -Subject $subject -Body $htmlReport
if ($reportstatus -ne "OK") {
SendMailv2 -To $STR_AdminReceivers -Subject $subject -Body $htmlReport
}
#endregion #endregion