giftfactory.blogg.se

Powershell script to monitor folder for new files
Powershell script to monitor folder for new files









powershell script to monitor folder for new files

First give the script a name, and make sure you know what the script is doing if someone asks you about it. Now its time to make SCOM understand the script we created. MAKE SURE NOT TO ENABLE THE MONITOR – we will do this in the end. (Please do not choose it to run every 5 seconds, since your database will fill up with data you dont need). Name the script something apropriate on the General tab, then create a schedule on how often you want this script to run. Select Scripting -> Powershell Based -> Powershell Script Two State Monitor, and create a new/select an existing MP to put this monitor into.

Powershell script to monitor folder for new files code#

Now we need to import this code into SCOM, and make sure that you get alerts when/if the state changes.įirst, create a new Windows-computer Availability Unit Monitor. (In this example you need to change the share names into your own shares) Now I should get an output ‘Folder is alive’ if the folders are accessable, and ‘Folder is dead’ if not. This is hardcoded, but can easily be changed.īefore doing this I just want to make a disclaimer saying, that I am not responsible for any of this code – I encourage you to test this in a non-production enviorenment before anything else. I started off by creating my powershell script – I wanted to keep it simple, so that the next guy could see what I have been doing. I’ve had this MP for a while, but never really used it so its about time. (And we hate that!) So i decided to give it a go with the SquaredUp Community Powershell Monitoring Management Pack.

powershell script to monitor folder for new files

We had a VBscript that monitored if our fileshares were up or down, but recently it started to fail – giving false positives. First of all, its been a while – but I am still here.











Powershell script to monitor folder for new files