PowerShell – Auto Discover SCOM Environment & RMS Emulator


The below script automatically discovers your entire SCOM environment and the server with the RMS emulator role without any user input. The only requirements are the OperationsManager and ActiveDirectory commandlets are available on the machine running the script.

###############################################################################
#                                                                             #
# ****************** CREATED BY MAURICE DALY ON 18/12/2013 ****************** #
#                                                                             #
# Automatically searches and discovers SCOM servers & SCOM RMS Emulator       #
#                                                                             #
# THIS SCRIPT IS USED AT YOUR OWN RISK. I ACCEPT NO RESPONSIBILITY FOR ANY    #
# ISSUES ARRISING FROM IT                                                     #
#                                                                             #
###############################################################################

#Import required modules
cls
Write-Host -ForegroundColor Yellow "****** IMPORTING POWERSHELL COMMANDLETS  *******"
Write-Host ""
Import-Module OperationsManager -ErrorAction Stop
Write-Host "Importing Operations Manager Commandlets"
Import-Module ActiveDirectory -ErrorAction Stop
Write-Host "Importing Active Directory Commandlets"

sleep -Seconds 5

#Detect SCOM Servers infastructure

$ADDetails = Get-ADDomain
$Domain = $ADDetails.DNSRoot
$SCOMServer = Get-ADObject -Filter "(ServicePrincipalNAme -like 'MSOM*')" -SearchBase (Get-ADDomain).DistinguishedName.tostring()  -Properties ServiceDNSName, ServiceClassName | where name -NotLike *SDK* | ForEach-Object {Write-Output $($_.Name + "." + $Domain)}
$SCOMClass = "Microsoft.Windows.Computer"

#Connects to SCOM environment
New-SCOMManagementGroupConnection $SCOMServer

cls
Write-Host -ForegroundColor Yellow "****** DISPLAYING YOUR SCOM ENVIRONMENT  *******"
Write-Host ""

#Displays SCOM Servers & RMS Emulator
Write-Host -ForegroundColor Green "Microsoft SCOM Management Server List"
Get-SCOMManagementServer | Sort-Object -Property DisplayName | ft
Write-Host ""
Write-Host -ForegroundColor Green "Microsoft SCOM RMS Emulator"
Get-SCOMRMSEmulator | ft

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