Tech Blog‎ > ‎

Powershell - Export Logs from SVN

posted Apr 17, 2013, 1:29 PM by Victor Zakharov   [ updated Apr 17, 2013, 1:29 PM ]
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):

([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:

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.