diff --git a/Hyper-V/HyperV-VM-Status-Report.ps1 b/Hyper-V/HyperV-VM-Status-Report.ps1 index 6bece78..9bd1a8c 100644 --- a/Hyper-V/HyperV-VM-Status-Report.ps1 +++ b/Hyper-V/HyperV-VM-Status-Report.ps1 @@ -12,7 +12,6 @@ .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. 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. 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 #General - $Version = "v1.0" + $Version = "v1.1" $logfilelocation = "$($MyInvocation.MyCommand.Path | Split-Path -Parent)\Logs" $logfilename = "$(Get-Date -Format yyyyMMddHHmmss).log" $summaryfilename = "$(Get-Date -Format yyyyMMddHHmmss)-Summary.txt" @@ -44,6 +43,7 @@ $STR_EmailSubject= "Hyper-V Status Report - $(Get-Date -Format "dd-MM-yyyy")" $STR_SMTPFromaddress = "ICT Servicedesk " $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 #region functions @@ -285,74 +285,79 @@ $htmlReport += "" #Generate VM Replication Health table - $htmlReport += @" -

Server: $hvserver - VM Replication Health

- - - - - - - - - - - -"@ - foreach ($vm in ($VMreplinfo | Where-Object {$_.HVServer -eq $hvserver})) { + if ($VMreplinfo | Where-Object {$_.HVServer -eq $hvserver}) { $htmlReport += @" - - $(switch ($vm.ReplicationHealth){ - 'Critical' {""} - 'Warning' {""} - default {""} - } ) - - - - - - - - - +

Server: $hvserver - VM Replication Health

+
VM NameStateHealthLastReplicationTimePrimaryServerReplicaServerModeRelation
$($vm.VMName)$($vm.ReplicationState)$($vm.ReplicationHealth)$($vm.LastReplicationTime)$($vm.PrimaryServer)$($vm.ReplicaServer)$($vm.ReplicationMode)$($vm.RelationshipType)
+ + + + + + + + + + "@ - } - $htmlReport += "
VM NameStateHealthLastReplicationTimePrimaryServerReplicaServerModeRelation
" + + foreach ($vm in ($VMreplinfo | Where-Object {$_.HVServer -eq $hvserver})) { + $htmlReport += @" + $(switch ($vm.ReplicationHealth){ + 'Critical' {""} + 'Warning' {""} + default {""} + } ) + $($vm.VMName) + $($vm.ReplicationState) + $($vm.ReplicationHealth) + $($vm.LastReplicationTime) + $($vm.PrimaryServer) + $($vm.ReplicaServer) + $($vm.ReplicationMode) + $($vm.RelationshipType) + +"@ + } + $htmlReport += "" + } + #Generate VM Metric details table - $htmlReport += @" -

Server: $hvserver - VM Metric details

- - - - - - - - - - -"@ - foreach ($vm in ($VMmetricinfo | Where-Object {$_.HVServer -eq $hvserver})) { + if ($VMmetricinfo | Where-Object {$_.HVServer -eq $hvserver}) { $htmlReport += @" - - $(switch ($vm.ReplicationHealth){ - 'Critical' {""} - 'Warning' {""} - default {""} - } ) - - - - - - - - +

Server: $hvserver - VM Metric details

+
VM NameAverage CPU Utilization (MHz)Average Memory (GB)Disk Space Used (GB)Inbound Network Traffic (GB)Outbound Network Traffic (GB)Metering data duration
$($vm.VMName)$($vm.AvgCPU)$($vm.AvgRAM)$($vm.TotalDisk)$($vm.InboundNWTraffic)$($vm.OutboundNWTraffic)$($vm.MeteringDuration)
+ + + + + + + + + "@ + foreach ($vm in ($VMmetricinfo | Where-Object {$_.HVServer -eq $hvserver})) { + $htmlReport += @" + + $(switch ($vm.ReplicationHealth){ + 'Critical' {""} + 'Warning' {""} + default {""} + } ) + + + + + + + + +"@ + } + $htmlReport += "
VM NameAverage CPU Utilization (MHz)Average Memory (GB)Disk Space Used (GB)Inbound Network Traffic (GB)Outbound Network Traffic (GB)Metering data duration
$($vm.VMName)$($vm.AvgCPU)$($vm.AvgRAM)$($vm.TotalDisk)$($vm.InboundNWTraffic)$($vm.OutboundNWTraffic)$($vm.MeteringDuration)
" } - $htmlReport += "" } $htmlReport += @"

This is an automated report.

@@ -372,5 +377,9 @@ else { $subject = "$STR_EmailSubject" } + SendMailv2 -To $STR_Receivers -Subject $subject -Body $htmlReport + if ($reportstatus -ne "OK") { + SendMailv2 -To $STR_AdminReceivers -Subject $subject -Body $htmlReport + } #endregion