22 Mar 2011

Set agent proxy enabled for all agents in SCOM

Some customers prefer to enable agent proxy on all agents.

There are 2 possible solutions in this case:
- running powershell script by schedule, which will set agent proxy enabled
- configure default global setting to make all new agents proxy enabled

Here's the script:

param($RMS)
## prepare OpsMgr shell 
if ((Get-PSSnapin | Where-Object {$_.Name -eq 'Microsoft.EnterpriseManagement.OperationsManager.Client'}) -eq $null) 
{ 
   Add-PSSnapin Microsoft.EnterpriseManagement.OperationsManager.Client -ErrorAction SilentlyContinue -ErrorVariable Err 
   if ($Err) { $(throw write-Host $Err) } 
} 
if ((Get-ManagementGroupConnection | Where-Object {$_.ManagementServerName -eq $RMS}) -eq $null) 
{    
   New-ManagementGroupConnection $RMS -ErrorAction SilentlyContinue -ErrorVariable Err 
   if ($Err) { $(throw write-Host $Err) } 
} 
if ((Get-PSDrive | Where-Object {$_.Name -eq 'Monitoring'}) -eq $null) 
{ 
   New-PSDrive -Name: Monitoring -PSProvider: OperationsManagerMonitoring -Root: \ -ErrorAction SilentlyContinue -ErrorVariable Err 
   if ($Err) { $(throw write-Host $Err) } 
} 
Set-Location Monitoring:\$RMS

## connect to management group 
$ManagementGroup = New-Object Microsoft.EnterpriseManagement.ManagementGroup($RMS) 
$ManagementGroup.Reconnect() 
 
## Script body(can be run from Operations Manager Shell directly) 
 
## set proxy enabled for all agents where it is disabled
$NoProxy = get-agent | where {$_.ProxyingEnabled -match "false"}
$NoProxy|foreach {$_.ProxyingEnabled = $true}
$NoProxy|foreach {$_.ApplyChanges()}

Here's the global setting:

Set-DefaultSetting -Name HealthService\ProxyingEnabled -Value True

No comments:

Post a Comment