System Center Operations Manager 2012 R2 (SCOM 2012 R2 / OpsMgr 2012 R2) Schulung / Training / Kurs System Center Operations Manager 2012 R2 (SCOM 2012 R2 / OpsMgr 2012 R2) Schulung / Training / Kurs System Center Operations Manager 2012 R2 (SCOM 2012 R2 / OpsMgr 2012 R2) Schulung / Training / Kurs

SCOM 2012 R2 - WiehE.D.V. - IT Consulting

SCOM 2012 R2:Emailreport zur ManagementServerGesundheit

Dieses Script prüft den Zustand der SCOM 2016 ManagementServerGesundheit und versendet einen Report per Email.

Getestet unter SCOM 2012 R2

Quelle: http://gallery.technet.microsoft.com/scriptcenter/SCOM-2012-Daily-Health-5950d801
Author: ScottMoss

This is an updated script from Jason Rydstrand's SCOM 2007 R2 daily check scipt. It has been updated to use Operations Manager 2012/2012 R2 cmdlets. This script should be run on a managment server in the management group that you would like the report based on. It should be run with an account that has administrative access to SCOM and the local machine that will be running it. See note in the script for more information. Change the following variable to configure the script to use your gmail account.

$UserName

$Password

$mailmessage.from.add

 

############################################################################## 
# 
#   SCOM2012Health-Check.ps1 
# 
#   Original Script by: Jason Rydstrand for 2007 R2 
#   http://blogs.technet.com/b/jasonrydstrand/archive/2013/03/27/daily-scom-health-check-with-powershell.aspx 
#   The script below has been updated to function for SCOM 2012/SCOM 2012 R2 
#   Modifications by: Scott Moss mvp Diese E-Mail-Adresse ist vor Spambots geschützt! Zur Anzeige muss JavaScript eingeschaltet sein! | twitter: jscottmoss 
#   The SCOM connection for posh was totally stolen from Bob Cornelissen! Thx Bob! 
#   Also thank you to Toa Yang for the sanity Check!  
#   Update $UserName and $Password for your email server on gMAIL  
#   Also update $mailmessage.from and $mailmessage.To.Add with who its coming from and going to 
#    
############################################################################## 
#Importing the SCOM PowerShell module 
Import-module OperationsManager 
#Connect to localhost when running on the management server 
$connect = New-SCOMManagementGroupConnection –ComputerName localhost 
 
# Or enable the two lines below and of course enter the FQDN of the management server in the first line. 
#$MS = "enter.fqdn.name.here" 
#$connect = New-SCOMManagementGroupConnection –ComputerName $MS 
 
# Create header for HTML Report 
$Head = "<!--mce:0-->" 
 
# Get status of Management Server Health and input them into report 
write-host "Getting Management Health Server States" -ForegroundColor Yellow  
$ReportOutput = "To enable HTML view, click on `"This message was converted to plain text.`" and select `"Display as HTML`"" 
$ReportOutput +"<p><H2>Management Servers not in Healthy States</H2></p>" 
 
$Count = Get-SCOMManagementServer | where {$_.HealthState -ne "Success"| Measure-Object 
 
if($Count.Count -gt 0) {  
 $ReportOutput += Get-SCOMManagementServer | where {$_.HealthState -ne "Success"| select Name,HealthState,IsRootManagementServer,IsGateway | ConvertTo-HTML -fragment 
} else {  
 $ReportOutput +"<p>All management servers are in healthy state.</p>" 
}  
 
 
# Get Agent Health Status and put none healthy ones into report 
write-host "Getting Agent Health Status" -ForegroundColor Yellow 
$MG = get-scommanagementgroup  
$criteria = new-object Microsoft.EnterpriseManagement.Monitoring.MonitoringObjectGenericCriteria("InMaintenanceMode=1"$objectsInMM = $MG.GetPartialMonitoringObjects($criteria.Criteria) 
$ObjectsFound = $objectsInMM | select-object DisplayName, @{name="Object Type";expression={foreach-object {$_.GetLeastDerivedNonAbstractMonitoringClass().DisplayName}}},@{name="StartTime";expression={foreach-object {$_.GetMaintenanceWindow().StartTime.ToLocalTime()}}},@{name="EndTime";expression={foreach-object {$_.GetMaintenanceWindow().ScheduledEndTime.ToLocalTime()}}},@{name="Path";expression={foreach-object {$_.Path}}},@{name="User";expression={foreach-object {$_.GetMaintenanceWindow().User}}},@{name="Reason";expression={foreach-object {$_.GetMaintenanceWindow().Reason}}},@{name="Comment";expression={foreach-object {$_.GetMaintenanceWindow().Comment}}} 
 
$ReportOutput +"<h2>Agents where Health State is not Green</h2>" 
#$ReportOutput += Get-Agent | where {$_.HealthState -ne "Success"} | Sort-Object HealthState -descending | select Name,HealthState | ConvertTo-HTML -fragment 
 
$Agents = Get-scomAgent | where {$_.HealthState -ne "Success"| Sort-Object HealthState -descending | select Name,HealthState 
 
$AgentTable = New-Object System.Data.DataTable "$AvailableTable" 
$AgentTable.Columns.Add((New-Object System.Data.DataColumn Name,([string]))) 
$AgentTable.Columns.Add((New-Object System.Data.DataColumn HealthState,([string]))) 
$AgentTable.Columns.Add((New-Object System.Data.DataColumn MM,([string]))) 
$AgentTable.Columns.Add((New-Object System.Data.DataColumn MMUser,([string]))) 
$AgentTable.Columns.Add((New-Object System.Data.DataColumn MMReason,([string]))) 
$AgentTable.Columns.Add((New-Object System.Data.DataColumn MMComment,([string]))) 
$AgentTable.Columns.Add((New-Object System.Data.DataColumn MMEndTime,([string]))) 
 
foreach ($Agent in $Agents) 
    { 
        $FoundObject = $null 
    $MaintenanceModeUser = $null 
    $MaintenanceModeComment = $null 
    $MaintenanceModeReason = $null 
    $MaintenanceModeEndTime = $null 
        $FoundObject = 0 
        $FoundObject = $objectsFound | ? {$_.DisplayName -match $Agent.Name -or $_.Path -match $Agent.Name} 
        if ($FoundObject -eq $null) 
            { 
                $MaintenanceMode = "No" 
                $MaintenanceObjectCount = 0 
            } 
        else 
            { 
                $MaintenanceMode = "Yes" 
                $MaintenanceObjectCount = $FoundObject.Count 
        $MaintenanceModeUser = (($FoundObject | Select User)[0]).User 
        $MaintenanceModeReason = (($FoundObject | Select Reason)[0]).Reason 
        $MaintenanceModeComment = (($FoundObject | Select Comment)[0]).Comment 
        $MaintenanceModeEndTime = ((($FoundObject | Select EndTime)[0]).EndTime).ToString() 
            } 
        $NewRow = $AgentTable.NewRow() 
        $NewRow.Name = ($Agent.Name).ToString() 
        $NewRow.HealthState = ($Agent.HealthState).ToString() 
        $NewRow.MM = $MaintenanceMode 
        $NewRow.MMUser = $MaintenanceModeUser 
        $NewRow.MMReason = $MaintenanceModeReason 
        $NewRow.MMComment = $MaintenanceModeComment 
        $NewRow.MMEndTime = $MaintenanceModeEndTime 
        $AgentTable.Rows.Add($NewRow) 
    } 
     
$ReportOutput +$AgentTable | Sort-Object MM | Select Name, HealthState, MM, MMUser, MMReason, MMComment, MMEndTime | ConvertTo-HTML -fragment 
 
# Get Alerts specific to Management Servers and put them in the report 
write-host "Getting Management Server Alerts" -ForegroundColor Yellow  
$ReportOutput +"<h2>Management Server Alerts</h2>" 
$ManagementServers = Get-SCOMManagementServer 
foreach ($ManagementServer in $ManagementServers){  
 $ReportOutput +"<h3>Alerts on " + $ManagementServer.ComputerName + "</h3>" 
 $ReportOutput += get-SCOMalert -Criteria ("NetbiosComputerName = '" + $ManagementServer.ComputerName + "'"| where {$_.ResolutionState -ne '255' -and $_.MonitoringObjectFullName -Match 'Microsoft.SystemCenter'| select TimeRaised,Name,Description,Severity | ConvertTo-HTML -fragment 
} 
 
# Get all alerts 
write-host "Getting all alerts" -ForegroundColor Yellow 
$Alerts = Get-SCOMAlert -Criteria 'ResolutionState < "255"' 
 
# Get alerts for last 24 hours 
write-host "Getting alerts for last 24 hours" -ForegroundColor Yellow 
$ReportOutput +"<h2>Top 10 Alerts With Same Name - 24 hours</h2>" 
$ReportOutput +$Alerts | where {$_.LastModified -le (Get-Date).addhours(-24)} | Group-Object Name | Sort-object Count -desc | select-Object -first 10 Count, Name | ConvertTo-HTML -fragment 
 
$ReportOutput +"<h2>Top 10 Repeating Alerts - 24 hours</h2>" 
$ReportOutput +$Alerts | where {$_.LastModified -le (Get-Date).addhours(-24)} | Sort-Object -desc RepeatCount | select-Object -first 10 RepeatCount, Name, MonitoringObjectPath, Description | ConvertTo-HTML -fragment 
 
# Get the Top 10 Unresolved alerts still in console and put them into report 
write-host "Getting Top 10 Unresolved Alerts With Same Name - All Time" -ForegroundColor Yellow  
$ReportOutput +"<h2>Top 10 Unresolved Alerts</h2>" 
$ReportOutput +$Alerts  | Group-Object Name | Sort-object Count -desc | select-Object -first 10 Count, Name | ConvertTo-HTML -fragment 
 
# Get the Top 10 Repeating Alerts and put them into report 
write-host "Getting Top 10 Repeating Alerts - All Time" -ForegroundColor Yellow  
$ReportOutput +"<h2>Top 10 Repeating Alerts</h2>" 
$ReportOutput +$Alerts | Sort -desc RepeatCount | select-object –first 10 Name, RepeatCount, MonitoringObjectPath, Description | ConvertTo-HTML -fragment 
 
# Get list of agents still in Pending State and put them into report 
write-host "Getting Agents in Pending State" -ForegroundColor Yellow  
$ReportOutput +"<h2>Agents in Pending State</h2>" 
$ReportOutput += Get-SCOMPendingManagement | sort AgentPendingActionType | select AgentName,ManagementServerName,AgentPendingActionType | ConvertTo-HTML -fragment 
 
# List Management Packs updated in last 24 hours 
write-host "Getting List Management Packs updated in last 24 hours" -ForegroundColor Yellow 
$ReportOutput +"<h2>Management Packs Updated</h2>" 
$MPDates = (Get-Date).adddays(-1) 
$ReportOutput += Get-SCManagementPack | Where {$_.LastModified -gt $MPDates| Select-Object DisplayName, LastModified | Sort LastModified | ConvertTo-Html -fragment 
 
# Take all $ReportOutput and combine it with $Body to create completed HTML output 
$Body = ConvertTo-HTML -head $Head -body "$ReportOutput" 
 
#$Body | Out-File C:\TEMP\HealthCheck-11-14-2012.html 
 
# Setup and send output as email message to GMAIL 
$SMTPServer = "smtp.gmail.com" 
$SMTPPort = "587" 
$Username = "Diese E-Mail-Adresse ist vor Spambots geschützt! Zur Anzeige muss JavaScript eingeschaltet sein!" 
$Password = "URGmailPWDHere!" 
$Body = ConvertTo-HTML -head $Head -body "$ReportOutput" 
$SmtpClient = New-Object system.net.mail.smtpClient($SMTPServer$SMTPPort); 
$MailMessage = New-Object system.net.mail.mailmessage 
$mailmessage.from = "Diese E-Mail-Adresse ist vor Spambots geschützt! Zur Anzeige muss JavaScript eingeschaltet sein!" 
$mailmessage.To.add("Diese E-Mail-Adresse ist vor Spambots geschützt! Zur Anzeige muss JavaScript eingeschaltet sein!"#$mailmessage.To.add("Diese E-Mail-Adresse ist vor Spambots geschützt! Zur Anzeige muss JavaScript eingeschaltet sein!") 
$mailmessage.Subject = "SCOM Daily Healthcheck Report" 
$MailMessage.IsBodyHtml = $true 
$smtpClient.EnableSSL = $true 
$smtpClient.Credentials = New-Object System.Net.NetworkCredential($Username$Password); 
$mailmessage.Body = $Body 
$smtpclient.Send($mailmessage

SCOM 2012 R2:Überarbeitete Managementpacks

In den vergangenen Tagen hat Microsoft eine Vielzahl an Management Packs für SCOM 2012 R2 aktualisiert.
Hier eine Übersicht über die Änderungen.
Quelle: Microsoft TechNet Blog

Windows Server DNS version: 7.1.10259.0

  • Fixed DNSMetrics2012R2Probe script can cause high CPU in MonitoringHost.exe

  • Changed display string for DNS server groups to be consistent with DHCP server group name

  • Added Dependency health monitor for the group Windows DNS Server 2012 R2 Group

 Windows Server DHCP version: 6.0.7230.0

  • Added Event 1044 to DHCPDatabase Integrity Monitor to Success State

  • Changed Monitor "DHCP Back Up Database Error Monitor" to have criteria for Healthy or to be Rule Based (it is Manual Reset)

    • Disabled the Unit Monitor Microsoft.Windows.DHCPServer.Library.Database.UnitMonitor.BackupAndRestore.1

    • Adding 2 rules to cover Warning and Error events.

  • Change Monitor "DHCP IPv4 Runtime DNS Registration Monitor" to have criteria for Healthy or to be Rule Based

    • Disabled the Unit Monitor ID: Microsoft.Windows.DHCPServer.Library.IPv4Runtime.UnitMonitor.DNSRegistration

  • Monitor "DHCP IPv4 Runtime Authorization Needed Monitor" never returns to green state

    • Adding Event ID 1044 to Healthy State expression

  • Add dependency monitor to DHCP 2012 R2 Servers group

 MSMQ 5.0, 6.0, 6.3 version: 7.1.10109.0

  • Updated to support monitoring workgroup machines

 Windows Server Cluster version: 6.0.7230.0

  • Fixed Cluster 2008 MP does not collect certain performance metrics.

  • Added Override to target Virtual Server class for the Discover Multiple Virtual Servers Property for Discovery Data Source to be set to True

 Active Directory Domain Services version: 6.0.8293.0

  • Fixed AD-Trust Monitor does not come back to healthy state

  • Fixed AD_Database_and_Log.vbs does not support using ‘.’ as decimal sign for non-English account.

 Windows Server Core Operating System version: 6.0.7230.0

  • Fixed Microsoft.Windows.Server.LogicalDiskDiscovery.Module.Type.vbs script does not discover logical disks with large disk size

  • Fixed Microsoft.Windows.Server.MonitorClusterDisks.vbs causes Operations Manager to fail at starting a process

  • Updated to support two configurable threshold values (waiters and timeouts) for triggering alert ‘MAX concurrent API Reached

  • Disable Logical disk fragmentation monitor by default

  • Add Task launch PowerShell session on the remote machine for All Computers

  • New Task added in Base OS Library MP and target to Windows Server Computer class, so this will be available for all OS versions.

  • Update Cluster Resource discovery to not discover VM's

  • Adding new Unit monitor to check for service state of Windows Remote Management service and also a task to start it.

  • Add Monitor for Windows Remote Management Service ( WinRM )

  • Fixing an error in a script with a missing alias in the MPElement expression.

  • Adding Slot ID property value to the discovery of network card for Windows Server 2012 and Windows Server 2012 R2