ActiveXperts Network Monitor ships with a powerful set of pre-defined checks. Each individual check has a static number of configuration items. To monitor other items, or to combine monitoring items, you can make use of custom PowerShell checks.
Most of the built-in checks have a PowerShell equivalent, implemented as a PowerShell (.ps1) script file. Out-of-the-box, each PowerShell script monitors the same items as the built-in check. Feel free to modify the script.
To add a new PowerShell-based Directory Service LDAP Server monitoring check, do the following:
- On the 'Monitor menu', open 'New Monitoring Check (Script)' and choose 'New PowerShell Check'. The 'PowerShell Check' dialog box appears;
- In the 'Script File' selection box, select 'DirectoryService-CheckLDAPServer.ps1.ps1';
- In the 'Script Parameters'group box enter the required parameters. You can also load a working sample first by clicking on the 'Click here to load a sample' link.
To customize the above monitoring check, click on the 'Edit button' next to the 'Script File' selection box. Notepad will be launched. You can now make changes to the PowerShell script.

DirectoryService-CheckLDAPServer.ps1 script source code
################################################################################# # ActiveXperts Network Monitor PowerShell script, (c) ActiveXperts Software B.V. # For more information about ActiveXperts Network Monitor, visit the ActiveXperts # Network Monitor web site at https://www.activexperts.com ################################################################################# # Script # DirectoryService-CheckLDAPServer.ps1 # Description: # Query an LDAP server and match the response # Parameters: # 1) strServer As String - Server to send the LDAP query to # 2) strExpected As String - Expected response # 3) strCredentials As String - Specify an empty string to use Metwork Monitor service credentials. # To use alternate credentials, enter a server that is defined in Server Credentials table. # (To define Server Credentials, choose Tools->Options->Server Credentials)' Usage: # Usage: # .\DirectoryService-CheckLDAPServer.ps1 '<strServer>' '<strExepected>' '[strCredentials]' ################################################################################# #Parameters param ( [string]$strServer, [string]$strExpected, [string]$strCredentials ) if ( ( [string]$strServer -eq "" ) -or ( [string]$strExpected -eq "" ) ) { $res = "UNCERTAIN: Invalid number of parameters - Usage: .\DirectoryService-CheckLDAPServer.ps1 '<strServer>' '<strExepected>' '[strCredentials]'" echo $res exit } ##Login## if ( $strCredentials -ne "" ) { $objCredentials = new-object -comobject ActiveXperts.NMServerCredentials $objRemoteServer = new-object -comobject ActiveXperts.RemoteServer $strUsername = $objCredentials.GetLogin($strCredentials) $strPassword = $objCredentials.GetPassword($strCredentials) if ( $strUsername -eq "" ) { $res = "UNCERTAIN: Alternate credentials[" + $strCredentials + "] where not found." echo $res exit } $objRemoteServer.Connect($strCredentials, $strUsername, $strPassword) if ( $objRemoteServer.LastError -ne 0 ) { $res = "UNCERTAIN: Login failed for user[" + $strUserName + "] on Server[" + $strServer + "]" echo $res exit } } $Dom = "LDAP://" + $strServer + "/RootDse" $objLDAP = new-object DirectoryServices.DirectoryEntry $Dom trap { Write-Host ` "UNCERTAIN: The server["$strServer"] Is not operational."; ` exit } & { $strPath = $objLDAP.Get( "DefaultNamingContext") } $strPath = $objLDAP.Get( "DefaultNamingContext") if ( $strPath.contains($strExpected) -eq 1 ) { $res = "SUCCESS: LDAP server was queried, response=[" + $strPath + "] matched string [" + $strExpected + "]" echo $res } else { $res = "ERROR: LDAP server was queried, response=[" + $strPath + "] did not match string [" + $strExpected + "]" echo $res } ##Logout## if ( $strCredentials -ne "" ) { $objRemoteServer.Disconnect($strCredentials) } exit