Much like the Operations Manager UI Console the Command Shell offers several ways to discover Windows computers. You can either search by computer name or search by LDAP query. Let start by looking at the diferences between each approach.
The following command defines a LDAP query and passes it to the New-WindowsDiscoveryConfiguration Cmdlet thereby creating an LDAP based WindowsDiscoveryConfiguration.
$query = New-LdapQueryDiscoveryCriteria –LdapQuery: “(sAMAccountType=805306369)(name=srv1.contoso.com*)” –Domain:”contoso.com”
$discoConfig = New-WindowsDiscoveryConfiguration –LdapQueryDiscoveryCriteria:$query
In contrast the following command defines a name based WindowsDiscoveryConfiguration that will direct discovery to find both srv1.contoso.com and srv2.contoso.com.
$discoConfig = New-WindowsDiscoveryConfiguration -ComputerName: "srv1.contoso.com", "srv2.contoso.com"
There is a lot more you can specify when defining a WindowsDiscoveryConfiguration. The following commands will direct the discovery module to use specific credentials, perform verification of each discovered Windows computer and constrain the type of discovered object to a Windows server. The ComputerType parameter is an enum that can be one of Workstation, Server, or Both. The PerformVerification switch is used to direct the discovery module to verify that only available computers should be returned.
# Prompt for credentials used to perform the discovery.
$creds = Get-Credential
# Define a WindowsDiscoveryConfiguration
$discoConfig = New-WindowsDiscoveryConfiguration –ComputerName: "srv3.contoso.com", "srv4.contoso.com" –PerformVerification: $true –ActionAccount:$creds -ComputerType: "Server"
# Select the Management Server used to run the discovery.
$managementServer = Get-ManagementServer –Root: $true
# Start the discovery process.
$discoResult = Start-Discovery –ManagementServer: $managementServer –WindowsDiscoveryConfiguration: $discoConfig
# Check that the discovery process discovered the Windows computers you specified.
# Last but not least install agents on the discovered computers.
Install-Agent –ManagementServer: $managementServer –AgentManagedComputer: $discoResult.CustomMonitoringObjects
Hope that helps and as always please post your questions and comments and I will make sure they are addressed in future posts.