For a clearer picture

Month: June 2018

PowerShell Monitor to monitor number of folders in a folder with diagnostic and recovery

Part 1 – The PowerShell

Part 2 – The Data Source and Probe

Part 3 – The Monitor Type

Part 4 – The Monitor

Part 5 – A diagnostic task to view all the folders in the top level folder

Part 6 – A recovery task to delete all the folders in the top level folder

Part 6 – The Recovery

And finally we have a recovery which will allow the operator to delete the folders in the top level folder.

This is the PowerShell code

And this is the recovery code

This shows the key piece of passing data from the monitor to the recovery.

Part 5 – The diagnostic

As a quick value add; we can do a diagnostic that we can run manually to list the folders in the top level folder.

The PowerShell code is here

And the diagnostic here

This is how we pass property bag data from our monitor to our diagnostic

Part 4 – The Monitor

And now we can finally author our monitor.

Right click on the folder FolderMonitoringCountFoldersInFolder and select Add, New Item, Empty Management Pack Fragment and call it 5_Monitor. Copy and paste the following code between the tags.