Home > SCOM 2012, System Center Family > Enable-SCOMMonitor

Enable-SCOMMonitor


We now have the capability to enable SCOM monitors via PowerShell

 

$MS=”XXXX” $MPName=”XXXX” $ClassName=”XXXX” $MonitorName=”XXXX”

if ((Get-PSSnapin | Where-Object {$_.Name -eq ‘Microsoft.EnterpriseManagement.OperationsManager.Client’}) -eq $null) { Write-Host Write-Host “File loaded.” Write-Host “Initializing shell for operations manager…” Write-Host “Add Microsoft.EnterpriseManagement.OperationsManager.Client snap in.” Add-PSSnapin Microsoft.EnterpriseManagement.OperationsManager.Client -ErrorAction SilentlyContinue -ErrorVariable Err

if ($Err) { $(throw write-Host $Err) } }

if ((Get-ManagementGroupConnection | Where-Object {$_.ManagementServerName -eq $MS}) -eq $null) { Write-Host “Connect to Management Server: $MS” New-ManagementGroupConnection $MS -ErrorAction SilentlyContinue -ErrorVariable Err if ($Err) { $(throw write-Host $Err) } }

if ((Get-PSDrive | Where-Object {$_.Name -eq ‘Monitoring’}) -eq $null) { Write-Host “Create Monitoring drive from Provider.” New-PSDrive -Name: Monitoring -PSProvider: OperationsManagerMonitoring -Root: \ -ErrorAction SilentlyContinue -ErrorVariable Err

if ($Err) { $(throw write-Host $Err) } Write-Host “Operations manager shell initialized.” Write-Host }

Set-Location Monitoring:\$MS

$MP = Get-SCOMManagementPack -displayname $MPName | where {$_.Sealed -eq $False} $Class = Get-SCOMClass -DisplayName $ClassName $Monitor = Get-SCOMMonitor -DisplayName $MonitorName Enable-SCOMMonitor -Class $Class -ManagementPack $MP -Monitor $Monitor -Enforce

Advertisements
  1. No comments yet.
  1. March 7, 2012 at 4:26 pm

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: