title: Powershell, svn, and authentication
body: <p>I can remote desktop into a given machine and run svn, without giving authentication information, and it works; my AD authentication allows me access to the repository I want. </p>
  
  <p>I can use Powershell to connect to the machine and execute svn commands, as well. However, when I do, I get "access forbidden". <code>[Environment]::UserName</code> appears with the username I expected (my AD username) when run from the script that's being remotely executed. </p>
  
  <p>What am I missing to make this work?</p>
  
  <p>Some code:</p>
  
  
  
  <pre class="lang-psh prettyprint-override"><code>$Session = New-PSSession -ComputerName $computerName;
  
  if (-Not ($Session)) {
      Write-Host "Did not create session!";
      Return;
  }
  
  Invoke-Command -Session $Session -FilePath 'switchAllRepositories.ps1' -ArgumentList $branchName;
  
  Remove-PSSession $Session;
  </code></pre>
  
  <p>and in switchAllRepositories, I have a parameter:</p>
  
  <pre class="lang-psh prettyprint-override"><code>Param(
    [string]$branchURL
  )
  </code></pre>
  
  <p>a series of calls like:</p>
  
  <pre class="lang-psh prettyprint-override"><code>If(Test-Path "C:\webfiles\repositoryname") {
      Write-Host "Switching repositoryname"
      SwitchRepo "repositoryname" ($branchURL) "C:\webfiles\repositoryname";
  }
  </code></pre>
  
  <p>which call:</p>
  
  <pre class="lang-psh prettyprint-override"><code>Function SwitchRepo ($repoName, $branchPath, $workingCopy)
  {
      $to = ("https://[url]/svn/" + $repoName + $branchPath);
      Write-Host "to $to";
  
      #debug
      $user = [Environment]::UserName
      Write-Host "as $user";
  
      $exe = "C:\Program Files\TortoiseSVN\bin\svn.exe";
      &amp;$exe switch "$to" "$WorkingCopy" --username [redacted] --password [redacted] --no-auth-cache --non-interactive --trust-server-cert
  
      if ($process.ExitCode -ne 0) {
          #$wshell = New-Object -ComObject Wscript.Shell
          #$wshell.Popup("Error switching " + $repoName,0,"Done",0x1)
          Write-Host "Error detected!"
      }
  }
  </code></pre>
  
  <p>The exact error is:</p>
  
  <blockquote>
    <p>svn: E175013: Unable to connect to a repository at URL
    '[snipped]'
        + CategoryInfo          : NotSpecified: (svn: E175013: U...eases/20150620':String) [], RemoteException
        + FullyQualifiedErrorId : NativeCommandError   svn: E175013: Access to '[snipped]' forbidden</p>
  </blockquote>