KB: Scripting the Ping MP with PowerShell

When dealing with large amounts of ping targets it is convenient to be able to add/remove them through PowerShell. This kb article contains a sample script for PowerShell (in conjunction with a DLL) to script all your ping targets in SCOM


You will need to download the zip containing the DLL here.

After the download unzip the files to for example C:\DevOpsPing\

Change the parameters in the PS script below and run the script on a MS server.

## =======================================================
## Add/change/delete by script a Ping Host and Ping Target
## =======================================================
## Opslogix(c)

$RMS = "localhost"

# The Ping Source Host to use
$pingSourceHostName = "DEVOM2012SP1-01.contoso.com"

# The Ping Target to check
$pingTargetName = ""
$pingTargetDisplayName = "Gateway"

# load the assemblies

# Connect to the Management Group
New-SCOMManagementGroupConnection $RMS
$managementGroup = Get-SCOMManagementGroup

# Create an instance of the ping class and load the management group
$PingObj = New-Object OpsLogix.IMP.Base.UI.PowershellPing

# Use the line below to add your ping source node

# Use the line below to add your ping target

# Use the line below to remove your ping target
# Uncomment below only if you want to delete the ping target
# $PingObj.RemoveTargetInstance($managementGroup,$pingSourceHostName,$pingTargetName,$pingTargetDisplayName)