Setting SCOM Agents to Remotely Manageable

When you manually install an agent, it is no longer ‘Remotely Manageable’ from the SCOM Console so this means there are certain things you cannot do remotely. This is really just a simple flag in the database, so to change it, you ‘ll either have to install the agent using the discovery wizard (or PowerShell)…or change the flag in the Operational Database.

 

So here’s a query to return which Agents which are set as manually installed:

select bme.DisplayName from MT_HealthService mths
INNER JOIN BaseManagedEntity bme on bme.BaseManagedEntityId = mths.BaseManagedEntityId
where IsManuallyInstalled = 1

 

The following query will set all agents back to Remotely Manageable.

UPDATE MT_HealthService
SET IsManuallyInstalled=0
WHERE IsManuallyInstalled=1

 

Now – the above query will set ALL agents back to “Remotely Manageable = Yes” in the console.  If you want to control it agent by agent – you need to specify it by name here:

UPDATE MT_HealthService
SET IsManuallyInstalled=0
WHERE IsManuallyInstalled=1
AND BaseManagedEntityId IN
(select BaseManagedEntityID from BaseManagedEntity
where BaseManagedTypeId = ‘AB4C891F-3359-3FB6-0704-075FBFE36710’
AND DisplayName = ‘server01.thescomlab.com’)

So just change ‘server01.thescomlab.com’ to the name of your server…

 

Alternatively, you can wrap all of this up nicely inside a PowerShell Script.

# $computername needs to be the FQDN of the Server the Agent is being installed on.
# Set ‘YOURMANAGEMENTSERVERNAME’ to the name of your OperationsManager Database Server.

Param (
[Parameter(Position=0,Mandatory=$true)]
[string]$computername
)
$RemotelyManageable = @”

UPDATE MT_HealthService
set IsManuallyInstalled=0
where IsManuallyInstalled=1
AND BaseManagedEntityId IN
(select BaseManagedEntityID from BaseManagedEntity
where BaseManagedTypeId = ‘AB4C891F-3359-3FB6-0704-075FBFE36710’
AND DisplayName = ‘$computername’)
“@
$SqlConnection = New-Object System.Data.SqlClient.SqlConnection
$SqlConnection.ConnectionString = “Server=YOURMANAGEMENTSERVERNAME;Database=OperationsManager;Integrated Security=True”
$SqlCmd = New-Object System.Data.SqlClient.SqlCommand
$SqlCmd.CommandText = $RemotelyManageable
$SqlCmd.Connection = $SqlConnection
$SqlAdapter = New-Object System.Data.SqlClient.SqlDataAdapter
$SqlAdapter.SelectCommand = $SqlCmd
$DataSet = New-Object System.Data.DataSet
$SqlAdapter.Fill($DataSet) | Out-Null
$SqlConnection.Close()
$DataSet.Tables[0]

 

To run the script, save it as a new powershell script and call it this way:

Set-AgentRemotelyManageable.ps1 AgentHostName.YourDomain.Com

 
Comments

No comments yet.

Leave a Reply