0

I'm trying to do an svn checkout or update from SVN using PowerShell 2.0 and SharpSVN 1.7?

When I run TortoiseSVN outside of Powershell - I get a certificate error, and have to accept with a click and then I am connected. In PowerShell using SharpSvn, I get the following error:

Exception calling "CheckOut" with "2" argument(s): "Unable to connect to a repository at URL '...'"
At Z:\Temp\SVNTEST\svntest.ps1:64 char:20
+ $svnClient.CheckOut <<<< ($repoUri, $svnLocalPath)
+ CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodException

The code is pretty staightforward, there ar some C# examples of adding an exception handler which traps an error and succeeds, I'm not sure if this is my issue or how to do this in PowerShell

Here's the code snippet - any help appreciated

[System.IO.Directory]::SetCurrentDirectory($currentScriptDirectory.Path)

$evidence = [System.Reflection.Assembly]::GetExecutingAssembly().Evidence

[Reflection.Assembly]::LoadFile(("...SharpSvn.dll"),$evidence)

$svnClient = new-object SharpSvn.SvnClient 

$repoUri = new-object SharpSvn.SvnUriTarget($svnUrl) 

$svnClient.Authentication.DefaultCredentials = New-Object System.Net.NetworkCredential($svnUsername,$svnPassword)

$svnClient.CheckOut($repoUri, $svnLocalPath) 
Andrey Chaschev
  • 16,160
  • 5
  • 51
  • 68

1 Answers1

1
$svnClient.Authentication.add_SslServerTrustHandlers({
        $_.AcceptedFailures = $_.Failures
        $_.Save = $True
    })
user160351
  • 11
  • 1
  • Add the above code right after the line: $svnClient.Authentication.DefaultCredentials = New-Object System.Net.NetworkCredential($svnUsername,$svnPassword) – user160351 Jan 07 '14 at 21:16