Install OpsMgr Agent-less remotely with Powershell

2:04 pm in Powershell, SytemCenter by alkin

In our previous post we installed the OpsMgr agent remotely with Poweshell and enabled agent proxying. Now we are going to monitor a server agentless via Powershell:


#=======================================================================
#
# NAME: Opsmgr 2012 Agent-less Install
#
# AUTHOR: Alexandre Verkinderen
# DATEĀ  : 10/23/2013
#
#Requirements: The Operations Manager Powershell module needs to be installed
#
# COMMENT: This script is designed to install OpsMgr 2012 agent-less
# The following need agent-less installation using default options: Add-SCOMAgentlessManagedComputer <a href="http://technet.microsoft.com/en-us/library/hh918462.aspx">http://technet.microsoft.com/en-us/library/hh918462.aspx</a> : SCDPM01, SCCM01
#=======================================================================

#Variables
$MS = "SCOM01.contoso.com"

invoke-command -ComputerName $MS{
$AgentList = @("scdpm01.contoso.com","sccm01.contoso.com")
 $MS = "SCOM01.contoso.com"

#Import PowerShell Modules
import-module OperationsManager
#Connect to OpsMgr Management Group
New-SCOMManagementGroupConnection -ComputerName $MS

#--------------------------------------------------------------
#OpsMgr Agent Installation
#-----------------------------------

Foreach($Agent in $AgentList)
{

Add-SCOMAgentlessManagedComputer -Name $Agent -ManagedByManagementServer (Get-SCOMManagementserver -Name $MS)

}
}

Thanks,

Alexandre Verkinderen