OpsMgr 2007: How to schedule discover and install agent as MOM 2005
Tarek Ismael writes: As Before in MOM 2005, you can automatic discover your server and install agents without run the wizard every time. Now in system center Operations Manager, this is not available but you can do this using Shell command. the Script can be using to run a Windows schedule task to discover and install Ops Mgr 2007 agent based on your LDAP queryparam ($OpsMgrservername,$Domainname)
#Initialize the OpsMgr Provider
Add-PSSnapin Microsoft.EnterpriseManagement.OperationsManager.Client
# Set the location to the root of the provider namespace.
cd OperationsManagerMonitoring::
#create a connection to the Management Group
New-ManagementGroupConnection $OpsMgrservername
#change the path
cd $OpsMgrservername
#configure query setting
$ldap_query = new-ldapquerydiscoverycriteria -domain $Domainname -ldapquery "(sAMAccountType=805306369)(name=*ABC*)"
#configure discovery setting
$windows_discovery_cfg = new-windowsdiscoveryconfiguration -ldapquery $ldap_query
# discoveryresults
$discovery_results = start-discovery -managementserver (get-managementserver)-windowsdiscoveryconfiguration $windows_discovery_cfg
#install Agent
install-agent -managementserver (get-managementserver) -agentmanagedcomputer $discovery_results.custommonitoringobjects
Save the file as Agentdiscoverinstall.ps1. Configure the Windows schedule task as Powershell.exe Agentdiscoverinstall.ps1 -OpsMgrservername:localhost -Domainname:YOURDOM








