Adding New Network Devices to SCOM Using PowerShell

Last week, I needed to write a PowerShell script to add iSCSI SAN devices into SCOM 2007 as network devices. I thought the script would be very straight forward, until I realised there is a limitation using SCOM PowerShell snap-in.

To explain it, let me firstly go through how to do this in SCOM console and then I’ll compare this process with using SCOM PowerShell cmdlets.

So, to add a new network device using SCOM console, it’s pretty easy:

1. Launch Discovery Wizard and choose “Network Devices”

2. Enter the network device information


3. Select the device from discovery result and choose a proxy agent for this network device


Please note the default proxy agent is set to the management server from previous step. it can be changed by click on Change button


It lists all possible proxy agents. There are 3 management servers in my test environment, SCOM01 is my RMS, SCOM02 is a management server and SCOMGW01 is a gateway server located in another untrusted forest. I have highlighted these 3 servers, notice the icon for management servers is different than other normal agents.

4. continue on and complete the rest steps of the wizard.

Now, let’s look at how to do this in PowerShell:

1. Get Network Device monitoring class

[sourcecode language=”powershell”]$networkdeviceclass = get-monitoringclass -name ‘System.NetworkDevice'[/sourcecode]

2. Create a new DeviceDiscoveryConfiguration object

[sourcecode language=”powershell”]$dc = new-devicediscoveryconfiguration -monitoringclass $networkdeviceclass –fromipaddress “” -toipaddress “”[/sourcecode]

3. Define SNMP community string

[sourcecode language=”powershell”]$encoding = new-object System.Text.UnicodeEncoding

$encodedCommunityString = $encoding.GetBytes("tyang")

$dc.ReadOnlyCommunity = [System.Convert]::ToBase64String($encodedCommunityString)[/sourcecode]

4. Default SNMP version is 2, if the network device requires version 1, set the device discovery configuration to use SNMP version 1:

[sourcecode language=”powershell”]$dc.snmpversion = 1[/sourcecode]

5. Define the management server to be used in the discovery

[sourcecode language=”powershell”]$NWDeviceMS = Get-ManagementServer | Where-object {$_.displayname –ieq “”}[/sourcecode]

6. Start discovery using the management server defined in step 5

[sourcecode language=”powershell”]$DiscoveryResult = Start-Discovery -managementserver $NWDeviceMS -DeviceDiscoveryConfiguration $dc[/sourcecode]

7. If discovery is successful, add the device into SCOM.

[sourcecode language=”powershell”]if ($discoveryresult.monitoringtaskresults[0].status -ieq "succeeded")
#code to add the device into SCOM

Well, here’s the issue:

if you use the Add-RemotelyManagedDevice cmdlet, you have to use a SCOM AGENT as the proxy agent. You CANNOT choose a management server as the proxy agent for the network devices you are about to add.



The management server is not an agent, get-agent cmdlet does not return management servers:


And if I use the management server in Add-RemotelyManagedDevice cmdlet, it will fail:


Basically, object type mismatch…

So, if we want to use a management server as the proxy agent for network devices, we CANNOT use Add-RemotelyManagedDevice cmdlet. It is a limitation in SCOM PowerShell snap-in. Instead, There is a method in the management server object called “InsertRemotelymanagedDevices”:


we have to use this method to add network devices.  Therefore, the script for step 7 should be:

[sourcecode language=”powershell”]if ($discoveryresult.monitoringtaskresults[0].status -ieq "succeeded")

8. Check result:



As you can see, the device has been successfully added.


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: