cancel
Showing results for 
Search instead for 
Did you mean: 
Create Post

File & Folder Details (PowerShell)

Get directory and child element details including folder count, file count, and the folder's total size.  It also records the newest and oldest file (with age) in that folder.  The folder you want to watch is the first (and only) script parameter which defaults to C:\Windows\Temp.

The component returns the following metrics

  • Age of Parent Path - the age of the parent folder, stored as "seconds ago" (i.e. 93 indicates that the folder was created/updated 93 seconds ago)
  • Child Folder Count - the number of child folders (collected recursively).
  • Child File Count - the number of child files (collected recursively).
  • Child File and Folder Size (bytes) - the total number of bytes used for storage of the contents.  This is stored as bytes to match the rest of the Orion infrastructure.
  • Newest File Age (seconds ago) - the age (and path in the message) of the newest file, regardless of location in the folder, stored as "seconds ago" (i.e. 93 indicates that the folder was created/updated 93 seconds ago)
  • Oldest File Age (seconds ago) - the age (and path in the message) of the oldest file, regardless of location in the folder, stored as "seconds ago" (i.e. 93 indicates that the folder was created/updated 93 seconds ago)
  • Folder Path Exists - does the parent folder exist.  1 = True / 0 = False

The template has been tested with Windows Server 2012-2019 using both the SolarWinds Orion Agent and using traditional WMI collection.  This script relies that you organization/security team are not blocking "admin" shares on the remote machines [\\COMPUTERNAME\D$\Folder\File.txt].

Example screenshot assigned to node "EASTHYV01A" with script parameter "H:\Hyper-V":

pastedImage_10.png

Labels (1)
Attachments
Comments

@KMSigma  this is great.. how can we make use of this in alerting for " when the folder is deleted" which i believe will be folder path existis in your above template.. but need to understand the alerting piece of it and usage...

This isn't really designed to be used for that level of monitoring.  Server Configuration Monitor is a better fit for that.

However - the "Folder Path Exists" going to 0 (from 1, which is the default) would indicate that the folder has been deleted, renamed, or moved.

Since the PowerShell responses go into the "Multiple Statistics Data" for components, your alert logic should look something like this:

KMSigma_0-1606768591928.png

If this triggers, you're going to want to be VERY detailed about the alert, the server and the path so that the recipients understand what the alert is trying to say.

Version history
Revision #:
1 of 1
Last update:
‎10-29-2019 01:36 PM
Updated by: