Query SCOM Object ID via PowerShell

I want to create a new dashboard programmatically based on servers (names associated to services) that are held in a CMDB. The CMDB holds the name of the server i.e. “SVRDC01.contoso.co.uk” I would like to query SCOM via PowerShell to get the Object ID so I can use it in my SCOM dashboard

1 Like

You can get SCOM Object IDs from powershell by using the Get-ScomClassInstance command. However, if you only want to select computers with a specific display name then you will need to pipe it in with a class. I’ve used a Windows Computer class here.

Try:

Get-ScomClass -Name Microsoft.Windows.Computer `
| Get-ScomClassInstance `
| where-object {$_.DisplayName -eq "SVRDC01.contoso.co.uk"} `
| select id
4 Likes

Stroke that. I was too late :slight_smile:

I can’t help you query your CMDB, but if we assume that’s already done, and you wan’t the windows computer object in SCOM, you could do it this way

<del>$class = get-scomclass -name Microsoft.Windows.Server.Computer
PS C:\> Get-SCOMClassInstance -Class $class | Where-Object {$_.DisplayName -eq "yourserver.fq.dn"} | select id</del>

Works great - just removed the tags

$class = get-scomclass -name Microsoft.Windows.Server.Computer
Get-SCOMClassInstance -Class $class | Where-Object {$_.DisplayName -eq “SVRDC01.contoso.co.uk”} | select id

Thank you for this - works a treat :slight_smile: