Discover and install agent using Powershell

Here's an example of how you can run discovery and agent installation using the OpsMgr Command Shell.

$query = New-LdapQueryDiscoveryCriteria -domain <your_domain> -ldapquery "(cn= <target_netbios_name> )"

$discoverycfg = New-WindowsDiscoveryConfiguration -ldapquery $query

$discoveryResults = Start-Discovery -managementServer (get-managementServer) -windowsDiscoveryConfiguration $discoverycfg

Install-Agent -managementServer (get-ManagementServer) -agentManagedComputer $discoveryResults.CustomMonitoringObjects

Note: This will configure the agent to report to the Management Server you are currently connected to while performing this action.