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 File Count 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 'File-CheckFileCount.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.

File-CheckFileCount.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 # File-FileCount.ps1 # Description: # Count the number of files in a directory and all subsirectories # Parameters: # 1) strPath - UNC formatted file path # 2) bIncludeDirsInCount - Also count a directory as a file # 3) nMax - Maximum number of files (and directories) allowed # 4) 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: # .\File-FileCount.ps1 '<\\Server\Share\Path>' '<True | False >' Max_Files '<alt-credentials> | <>' # Sample: # .\File-FileCount.ps1 '\\localhost\c$\windows\system32' 'True' 10000 '' ################################################################################# # Parameters param ( [string]$strPath, [string]$bIncludeDirsInCount, [string]$nMax, [string]$strAltCredentials ) cls # Check paramters input if( [string]$strPath -eq "" -or [string]$bIncludeDirsInCount -eq "" -or [string]$nMax -eq "") { echo "UNCERTAIN: Invalid number of parameters - Usage: .\File-FileCount.ps1 '<\\Server\Share\Path>' '<True | False >' Max_Files '<alt-credentials> | <>'" exit } # Create object if( [string]$strAltCredentials -eq "" ) { #$objPath = Get-WmiObject -ComputerName $strComputer -Class Win32_OperatingSystem $exists = Test-Path $strPath } else { $objCredentials = new-object -comobject ActiveXperts.NMServerCredentials $objRemoteServer = new-object -comobject ActiveXperts.RemoteServer $strUsername = $objCredentials.GetLogin($strAltCredentials) $strPassword = $objCredentials.GetPassword($strAltCredentials) If ($strUsername -eq "") { $res = "UNCERTAIN: Alternate credentials for [" + $strAltCredentials + "] was not found" echo $res exit } $objRemoteServer.Connect($strAltCredentials,$strUsername,$strPassword) if ($objRemoteServer.LastError -ne 0) { $res = "UNCERTAIN: Unable to connect with Altername credentails[" + $strAltCredentials + "]" echo $res exit } $exists = Test-Path $strPath } ################################################################################# # THE SCRIPT ITSELF ################################################################################# if (!$exists) { $res = "UNCERTAIN: Path[" + $strPath + "] does not exitst" echo $res exit } if ($strUsername -ne $null) { $objRemoteServer.Disconnect($strAltCredentials) } $nCountFiles = (get-childitem $strPath | ?{!($_.PSIsContainer)}).Count if ($bIncludeDirsInCount -eq "True") { $nCountDirectories = (get-childitem $strPath | ?{$_.PSIsContainer}).Count $nTotalCount = $nCountFiles + $nCountDirectories } else { $nTotalCount = $nCountFiles } if ($nTotalCount -gt $nMax) { $res = "ERROR: " } else { $res = "SUCCESS: " } $res = $res + "Number of files=[" + $nTotalCount + "], maximum allowed=[" + $nMax + "]" echo $res exit