Posts

Showing posts from May, 2022

Create discovery override with PowerShell

This is a quick & dirty to create the overrides that disable the failover check for agents from my SCOM Admin mp. $output_overrides="" $a=gc C:\temp\file.txt foreach ($i in $a) { $GUID=[guid]::NewGuid().ToString("N") $Id="OverrideForDiscoverySCOMDiscoveryWindowsComputerClassForContextMicrosoftSystemCenterHealthService$GUID" $output_overrides+="<DiscoveryConfigurationOverride ID=""$ID"" Context=""SystemCenter!Microsoft.SystemCenter.HealthService"" ContextInstance=""$i"" Enforced=""false"" Discovery=""Admin!SCOM.Discovery.WindowsComputerClass"" Parameter=""IgnoreAgentMgmtGroups"" Module=""DS""><Value>MG_group</Value></DiscoveryConfigurationOverride>" } $output_mp=$output_overrides $output_mp | Out-File "_Overrides.xml"

Get health service IDs from file

This reads in a list of computer names and gets the health service ID for each one and writes the output to screen and file. [int]$count="" # need to declare or $count gets weird. $fqdn="" $file="" $file+="FQDN,ID`r" $a=gc C:\temp\file.txt | sort $output="c:\temp\HealthServiceIDs.csv" foreach ($i in $a) { $b=Get-SCOMClass -Name Microsoft.SystemCenter.HealthService | Get-SCOMClassInstance | where {$_.displayname -eq $i} $fqdn=$b.displayname $id=$b.id write-host "$fqdn, $id" $file+="$fqdn,$id`r" } write-host "Exporting output to $output" $file | out-file $output

Load balance agents

This will setup new primary and failover servers for agents reporting to a gateway. It assumes you only have 1 failover server and you can filter for the agents you want by domain name. Change  Get-SCOMGatewayManagementServer to  Get-SCOMManagementServer for agents reporting to management servers. $Server1=" GW1_FQDN " $Server2=" GW2_FQDN " $Primary= Get-SCOMGatewayManagementServer -Name $Server1 $Failover= Get-SCOMGatewayManagementServer -Name $Server2 $Agents=Get-SCOMAgent | where {$_.PrincipalName -match " AGENT_FQDN "} | sort PrincipalName foreach ($Agent in $Agents) { $Count+=1 $Fqdn=$Agent.DisplayName $AgentName=Get-SCOMAgent -Name $Fqdn if($Count %2 -eq 0) { write-host "$Count, Agent: $Fqdn, Primary: $Server1, Failover: $Server2" Set-SCOMParentManagementServer -Agent $AgentName -FailoverServer $NULL # Need this or you get error "The failover server xxx cannot be the same as the primary server." Set-SCOMParentManagementServer

Reset monitor

This example shows how to reset the Windows Inventory Script monitor. You first need to get the dot name of the monitor and the class the monitor targets. To get the class run this: (get-scommonitor -name SCOM.Monitor.WindowsInventoryScript).target.Identifier.path You also need to confirm the severity of the monitor or it won't work – sometimes alert severity does not match severity in health explorer. Important: This can be slow. I am not sure it is the best way to reset monitors, but it works. $Monitor="SCOM.Monitor.WindowsInventoryScript" $Class="Microsoft.Windows.Computer" $Severity="Warning" # Must match health state of the monitor (Success, Error, Warning) $MonitorToReset = Get-SCOMMonitor -Name $Monitor $Monitoringclass = Get-SCOMClass -Name $Class $Monitoringclass | Get-SCOMClassInstance | where {$_.HealthState -eq $Severity} | foreach {$_.ResetMonitoringState($MonitorToReset) | select Status} This is something I was messing around with when I

Install SCOM agent without APM

I've never had a need to install the APM component of an agent - it installs by default running it manually (and possible pushing from console?). This command will install without APM: msiexec.exe /i MOMAgent.msi /qb /l* LOG_FILE  USE_SETTINGS_FROM_AD=0 MANAGEMENT_GROUP= MGMT_GROUP_NAME  MANAGEMENT_SERVER_DNS= MGMT_SERVER  ENABLE_ERROR_REPORTING=0 ACTIONS_USE_COMPUTER_ACCOUNT=1 USE_MANUALLY_SPECIFIED_SETTINGS=1 NOAPM=1 AcceptEndUserLicenseAgreement=1

Use old SCOM 2007 dashboards

You can import old SCOM 2007 era dashboards in newer versions of SCOM. Download the mps here . I'm not sure which zip file it is but I imported the mp named OpsMgrR2Dashboards (version 1.0.0.2) into SCOM 2016 and they worked. After you import the mp it will create a folder structure in the Monitoring pane and you just copy the view you want into your folder.