Share via


Monitor File Size

Test-FileSizeUntil monitors the size of a file and triggers an action when it reaches a certain value. Basically I wrote it for a colleague who needs to create an action when a log file reaches a specific size. It monitors the size periodically; by default every 30 seconds and this behaviour can be changed by setting -Interval to anything you want (-Interval value is in seconds)

-Size parameter is the targeted size of the file; thanks to Powershell you can use values like 10KB, 1MB, 3GB

 Test-FileSizeUntil returns the job object when it is used with "-AsJob $true" parameter; please note that you have to copy Test-FileSizeUntil.ps1 file under "C:\ps\library" otherwise script does not function with "AsJob" parameter. Please check How Do I Use the Functions Provided in This Blog post for more information

Below you may see the usage of the function; I decided not to copy-paste script anymore inside of the blog; instead check the attachment

Test-FileSizeUntil

Cheers, CanD

 

Test-FileSizeUntil.ps1

Comments

  • Anonymous
    January 13, 2010
    Had to figure out where the attachment really was :) thanks for the link..
  • Anonymous
    August 14, 2012
    Is this script safe to run to monitor the size of an MS Access 2003 database?