1

I am wondering if anyone might know a way I could set up the automatic generation of a file changelog in a directory in windows server 2012. We have a collection of word, excell, and pdf files that I am currently having to create a changelog manually on a weekly basis. I wonder if it's possible to have windows handle this process. Any help or guidance would be greatly appreciated.

  • 1
    It can be useful to show what you've done to try to solve the problem yourself. – Drew Khoury Jan 19 '15 at 23:01
  • Yeah, this is too broad to answer usefully. I can say "yes," but that hardly gets you closer to solving whatever problem you're having. What information, exactly, do you want to log? – HopelessN00b Jan 19 '15 at 23:23
  • Information to log, file name/path, date-time modified, modified by (user name) I have not taken any steps so far to automate this process. Right now I do a date modified search of all files in the directory and look at when they were modified and update a changelog.txt file in the root of that directory. – user3538260 Jan 19 '15 at 23:43
1

Use WMI. Here is a vbscript version explaining how to use __InstanceOperationEvent from CIM_DirectoryContainsFile

http://www.codeproject.com/Articles/42212/WMI-and-File-System-Monitoring

This can be slow in 2008 but seems to run file in 2012

Another option is to use the filewatcher:

Write-Verbose ("Initializing FileSystemWatcher") -Verbose
$fileWatcher = New-Object System.IO.FileSystemWatcher
$fileWatcher.Path = "C:\folder"
Register-ObjectEvent -InputObject $fileWatcher -EventName Created -SourceIdentifier File.Created -Action {
        $Global:t = $event
        Write-Host ("File/Folder Created: {0} on {1}" -f `
        $event.SourceEventArgs.Name,
        (Split-Path $event.SourceEventArgs.FullPath)) -BackgroundColor Black -ForegroundColor Red 
        } | Out-Null
Register-ObjectEvent -InputObject $fileWatcher -EventName Deleted -SourceIdentifier File.Deleted -Action {
        $Global:t = $event
        Write-Host ("File/Folder Deleted: {0} on {1}" -f `
        $event.SourceEventArgs.Name,
        (Split-Path $event.SourceEventArgs.FullPath)) -BackgroundColor Black -ForegroundColor Red
    } | Out-Null
    Register-ObjectEvent -InputObject $fileWatcher -EventName Changed -SourceIdentifier File.Changed -Action {
        $Global:t = $event
        Write-Host ("File/Folder Changed: {0} on {1}" -f `
        $event.SourceEventArgs.Name,
        (Split-Path $event.SourceEventArgs.FullPath)) -BackgroundColor Black -ForegroundColor Red
    } | Out-Null
0

I recommend Jim B's solution with WMI, but if you want something simpler with powershell:

Dir C:\folder -r | ? {! $_.PSIsContainer -AND $_.lastwritetime -ge '04/18/14'} > changed.txt

This creates a file called changed.txt with every file changed in c:\folder (and it's subdirectories) since 04/18/14.

(credits: I got this from user nixda here)

You can add this script to your Task Scheduler to run every day.

I don't know of any way to get the information of which user changed the file. It could be done from within Word and Excel files in VBA.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.