I need to create a MP that will watch for if a file exists and alert if it does not as well as watch the file age and if it is older than 10 minutes raise an alert. I know there used to be a MP out there that could help with this but I am having trouble finding it at the moment.
We do ours with powershell these days - this is an example of a folder age in hours, writing back to the event log and to SCOM for health
#Parameters
param($threshold, $folder)
#$threshold = â4â
#$folder = âD:\FTPâ
$today = Get-Date
write-output âTodays date isâ $today
$limit = (Get-Date).AddHours(-$threshold)
Write-output âThreshold date isâ $limit
$folderage = (Get-Item $folder).LastAccessTime
Write-output âFolder Age isâ$folderage
if ($folderage -gt $limit){$Result = âSuccessâ} ELSE {$Result = âErrorâ}
$Result
Write-EventLog -LogName âOperations Managerâ -Source âHealth Service Scriptâ -EntryType Information -EventId 9100 -Message âFolder Write Monitoring Script Running with the following output:â$folder hasnât been written to since $folderage , $resultâ
#API Object
$api = new-object -comObject âMOM.ScriptAPIâ
$bag = $api.CreatePropertyBag()
$bag.AddValue(âHealthâ,$Result)
$bag.AddValue(âFolderAgeâ,$FolderAge)
$bag.AddValue(âThresholdâ,$threshold)
#$api.return($bag)
$bag