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 Group Membership 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-CheckGroupMembership.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-CheckGroupMembership.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-CheckGroupMembership.ps1 # Description: # Check if a user, specified by strUser, is member of group strGroup on domain strDomain # Parameters: # 1) strDomain As String - Domain that holds the user- and group account # 2) strGroup As String - Domain group name # 3) strUser As String - User name # Usage: # .\DirectoryService-CheckGroupMembership.ps1 '<Domain>' '<Domain Group>' '<Domain Account>' # Sample: # .\DirectoryService-CheckGroupMembership.ps1 'DOMAIN01' 'Guests' 'Guest' ################################################################################# #Parameters param ( [string] $strDomain, [string] $strGroup, [string] $strUser ) if ( ( [string]$strDomain -eq "" ) -or ( [string]$strGroup -eq "" ) -or ( [string]$strUser -eq "" ) ) { $res = "UNCERTAIN: Invalid number of parameters - Usage: .\DirectoryService-CheckGroupMembership.ps1 '<strDomain>' '<strGroup>' '<strUser>'" echo $res exit } $command = "WinNT://" + $strDomain + "/" + $strGroup + ",group" $objGroup = [ADSI]$command if ( $objGroup.Name -eq $null ) { $res = "UNCERTAIN: Domain[" + $strDomain + "] or Group[" + $strGroup + "] does not exist" echo $res exit } $objMembers = @($objGroup.psbase.Invoke("Members")) $objMembers | ForEach-Object { if ($_.GetType().InvokeMember("Name",'GetProperty',$null,$_,$null) -eq $strUser) { $strResult = $_.GetType().InvokeMember("Name",'GetProperty',$null,$_,$null) } } if ( $strResult -ne $null ) { $res = "SUCCESS: [" + $strUser + "] is member of group [" + $strGroup + "]" echo $res exit } else { $res = "ERROR: [" + $strUser + "] is NOT member of group [" + $strGroup + "]" echo $res exit }