Monday, July 23, 2012

SCOM 2012 - Export List of Agent Managed Devices to CSV File

I had a requirement today to export a list of all the SCOM / OpsMgr 2012 agent managed devices to a CSV file and thought I'd do up a quick post in case anyone else finds it useful.

This also might come in handy as an add-in for your System Center 2012 Orchestrator runbooks too.

All that's needed is just a single line of PowerShell as follows:

SCOM 2012

get-scomagent|export-csv -notype c:\scomagentdevices.csv

SCOM 2007 R2

get-agent|export-csv -notype c:\scomagentdevices.csv

Just copy and paste the relevant line of script from above into PowerShell on one of your SCOM management servers to create a file on the C:\ drive called 'scomagentdevices.csv'. This CSV file contains all of the information available on the agent such as -Patchlist, PrimaryManagementServerName, ManagementGroup, ID, LastModified, Name, DisplayName, HostComputer - etc.

You can easily scope down the criteria to be exported by simply modifying the PowerShell line above to include a property value such as just the DisplayName as below:

SCOM 2012

get-scomagent|select DisplayName|export-csv -notype c:\scomagentdevices.csv

If you are presented with any errors within the Operations Manager Shell when you first open it such as:

The term '.\OperationsManager\Functions.ps1' is not recognized as the name of a
cmdlet, function, script file, or operable program. Check the spelling of the
name, or if a path was included, verify that the path is correct and try again.
At line:1 char:67
+ Import-Module OperationsManager; .\OperationsManager\Functions.ps1 <<<< ; .\O
+ CategoryInfo : ObjectNotFound: (.\OperationsManager\Functions.p
s1:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException

Then simply type the following in before running the export line of script outlined above:

import-module OperationsManager

Hopefully someone else finds this helpful too!


  1. What about if I want to export the members of a group?

    1. Use this to get group members:

      Get-SCOMGroup -DisplayName "<DisplayName of Group" | Get-SCOMClassInstance | export-csv -notype C:\exportgroupmembers.csv

  2. This is great but apparently only shows Windows agents. Any solution for finding all agents?

  3. how to get the list of agents reporting to a particular management server