Skip to content

Instantly share code, notes, and snippets.

@ebibibi
Created November 12, 2013 07:14
Show Gist options
  • Select an option

  • Save ebibibi/7426819 to your computer and use it in GitHub Desktop.

Select an option

Save ebibibi/7426819 to your computer and use it in GitHub Desktop.
This script installs SCOM agents to several clients. ex) .\Install-SCOMAgent.ps1 -ServerName scomserver.domain.name -Targets @("client1.domain.name", "client2.domain.name")
#This script installs SCOM agents to several clients.
#
#ex)
#.\Install-SCOMAgent.ps1 -ServerName scomserver.domain.name -Targets @("client1.domain.name", "client2.domain.name")
Param(
[parameter(mandatory=$true)]$ServerName,
[parameter(mandatory=$true)]$Targets
)
$InstallAccount = Get-Credential
$session = New-PSSession -ComputerName $ServerName -Credential $InstallAccount
Invoke-Command -Session $session -ScriptBlock {
Import-Module OperationsManager
foreach($Target in $using:Targets) {
Write-Host "Install SCOM Agent to $Target ..."
$PrimaryMgmtServer = Get-SCOMManagementServer -Name $using:ServerName
Install-SCOMAgent -Name $Target -PrimaryManagementServer $PrimaryMgmtServer -ActionAccount $using:InstallAccount
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment