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


Cheers, CanD