Last week the SCOM admin from my customer asked me to help out with a PowerShell command he was trying.
A little background information:
We introduced the SQL Server Management Pack in SCOM and chose to run it under domain credentials instead of local system.
First we’ll need to create a variable which stores the runas account:
1 |
$RunAs = Get-SCOMRunAsAccount "sql action account" |
Second we’ll want to get a list of names from the servers we want the Management Pack to monitor:
1 |
$distlist = Get-SCOMGroup -DisplayName "sql computers" | Get-SCOMClassInstance | Select-Object -Property DisplayName |
But SCOM doesn’t work with server names, it works with SCOM agents.
So to get a list of SCOM agents on those SQL Servers:
1 |
$distribution = $distlist | foreach {Get-SCOMAgent -Name $_.DisplayName} |
Next up will be to actually configure the runas account on those servers:
1 |
Set-SCOMRunAsDistribution (Get-SCOMRunAccount "sql action account") -MoreSecure -SecureDistribution $distribution |
And last we’ll actually want to see if our actions had any effect:
1 |
Get-SCOMRunAsDistribution (Get-SCOMRunAsAccount "sql action account") |
Or when you want to see the actual list of servers the runas account has been distributed to, expand the SecureDistribution property:
1 |
Get-SCOMRunAsDistribution (Get-SCOMRunAsAccount "sql action account") | Select-Object -Property securedistribution |