Pages

10/03/2011

Automated Remote Install of SCOM client

###############################################################################################################
#  SCOM-INST.PS1
# Install SCOM Agent on a list of machines.

$rootMS = "RMS01"
$list = "c:\server-list.txt"
clear-host
$Servers = Get-Content $list

#attach SCOM SnapIn
    Add-PSSnapin "Microsoft.EnterpriseManagement.OperationsManager.Client" -ErrorVariable errSnapin;
    Set-Location "OperationsManagerMonitoring::" -ErrorVariable errSnapin;
    new-managementGroupConnection -ConnectionString:$rootMS -ErrorVariable errSnapin;
    set-location $rootMS -ErrorVariable errSnapin;
#
#install SCOM client
    $DiscoverCnfg = New-WindowsDiscoveryConfiguration -computername:$servers -performverification:$true

-computertype:"server"
    $ms = Get-rootManagementServer
    $DiscoverResults = Start-Discovery -managementserver $ms -windowsdiscoveryconfiguration:$DiscoverCnfg

$DiscoverResults.CustomMonitoringObjects
    if ($DiscoverResults.CustomMonitoringObjects) {
        install-agent -ManagementServer $ms -AgentManagedComputer: $DiscoverResults.custommonitoringobjects
        }
    else {
        write-host "ERROR:  Machine(s) not found"
        }


#
Write-Host "Press any key to continue ..."
$x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")