This page looks best with JavaScript enabled

Powershell - Export Logs from SVN

 ·   ·  ☕ 1 min read

You will need a command line SVN tool for this to work, for example, SlikSVN.
Install it on your machine and configure environment:path to point to its binaries.
Then use below Powershell script (I called it Get-SvnLog.ps1):

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
([xml](svn log -v --xml)).log.logentry | % {
  $entry = $_;
  $_.paths.path | foreach {
    $obj = 1 | select -Property Revision,Author,Date,Message,Action,FilePath;
    $obj.Revision = [int]$entry.Revision;
    $obj.Author = $entry.Author;
    $obj.Date = Get-Date $entry.Date;
    $obj.Message = $entry.msg;
    $obj.Action = $_.action;
    $obj.FilePath = $_.InnerText;
    return $obj;
  }
}

Like the following:

1
PATH_TO_SCRIPT\Get-SvnLog.ps1 | Export-Csv -Path YourOutputFile.csv

It needs to be executed under a versioned folder, and it will output a log for that folder.
The key part here is svn log -v --xml, which gives you an XML file representation of the SVN log.
Rest is parsing that XML into a list of Powershell objects, then pipelined with Export-Csv.

If being inside a folder in question is unproductive, you can add $path parameter to the script and then change the call to: svn log -v --xml $path.


Victor Zakharov
WRITTEN BY
Victor Zakharov
Web Developer (Angular/.NET)