How To Monitor a Folder changes using Powershell
In our environment, large numbers of users are working on a daily basis and it very difficult to track what file they have modified and which time. To handle this scenario, my team was requested to monitor a directory for any file changes and receive alerts of those changes when they trying to update/Delete/renamed/created in a specific location inside the service and this requirement made me create this post. In this post, we will discuss how to monitor changes in the folder including sub-files, and log in to the log text file.
STEP #1
To monitor a folder for new files in Windows with PowerShell, we can use a .NET class called FileSystemWatcher. This class is in the System.IO namespace and can be created with the New-Object cmdlet.
$filewatcher = New-Object System.IO.FileSystemWatcher
please refer the source : https://dotnet-helpers.com/powershell/how-to-monitor-a-folder-changes-using-powershell/
Comments
Post a Comment
We appreciate your valuable feedback and comments