다음을 통해 공유


Windows PowerShell: How to Monitor Folder for New Files

A folder that contains sensitive data should not be getting new files without your knowledge. To stay informed about new files in important folders, you can make a point of manually executing a simple PowerShell script on a regular basis to get all files created or modified after you last ran the script. The PowerShell script provided above searches a folder on a Windows share for new objects and outputs the results to your console window.

1. Open the PowerShell ISE → Run the following script, adjusting the path to the directory and the timeframe:

Get-ChildItem -Path \\pdc\Shared\Accounting\*.* -Filter * | ? {
   $_.LastWriteTime -gt (Get-Date).AddDays(-1)
}

2. Review the results

https://img.netwrix.com/howtos/powershell_new_files_report.png

Credits

Originally published at: https://www.netwrix.com/how_to_monitor_a_folder_for_new_files.html