trigger an alarm if there are too many files in a folder
Hello,
we have a folder on a Windows file server into which files are constantly being added, which are then automatically processed and deleted by a process.
If an error occurs, more and more files accumulate in this folder, then we would like to have an alarm that says there are too many files in the folder (for example, more than 10). How can I implement this with PowerShell?
Comments
-
Heres one way. Maybe theres a better way.
- Create a script that counts files & folders of a specified directory
# Specify the path to the folder
$folderPath = "C:\path\to\folder"
# Count the number of files and folders combined
$itemCount = (Get-ChildItem -Path $folderPath).Count
# Output the result
Write-Host "$itemCount"
2. Create a Threshold, that monitors the number.
3. Apply threshold to devices
Hope this helps, good luck 😁
4 -
Thank you, it works, but there is always only 1 alarm e-mail, even if another file is added in a short time.
0 -
You can duplicate the threshold and have another value set at 20.
example.
informational status at 10, warning at 20, critical at 30.
0
Topics
- All Topics
- 40 Getting started
- 24 Read before posting
- 8 Meet and greet
- 219 General
- 59 News and announcements
- Swag
- 1 Roadmap updates
- 68 Resources
- 9 Knowledge Base
- 13 Webinars
- 1 Shared Script Library
- 2 Blog
- 15 Pro Tips
- 26 Got an idea?
- 1 Atera Academy
- 1 ActionAI
- 1 Copilot
- 123 Remote Monitoring and Management
- 77 Remote Monitoring
- 23 Patch Management
- 98 Professional Services Automation
- 61 Helpdesk
- 17 Billing
- 18 Reporting
- 33 Integrations & add-ons
- 19 Integrations
- 10 Add-ons
- 99 Scripting and automations
- 58 Scripts
- 29 Automations