title: 401 Unauthorized Sonarqube Analysis with TFS2017
body: <p>I setup a SonarQube server and included the BuildTask Steps in the TFS2017 Build process. TFS is an on-premise setup.</p>
  
  <p>On "Complete SonarQube analysis" build step i get the following error:</p>
  
  <pre><code>2017-01-30T08:54:30.7388183Z 09:54:30.676  Post-processing succeeded.
  2017-01-30T08:54:32.1607278Z ##[error]System.Management.Automation.CmdletInvocationException: {"err_code":401,"err_msg":"Unauthorized"} ---&gt; System.Net.WebException: Der Remoteserver hat einen Fehler zurückgegeben: (401) Nicht autorisiert.
  2017-01-30T08:54:32.1607278Z    bei Microsoft.PowerShell.Commands.WebRequestPSCmdlet.GetResponse(WebRequest request)
  2017-01-30T08:54:32.1607278Z    bei Microsoft.PowerShell.Commands.WebRequestPSCmdlet.ProcessRecord()
  2017-01-30T08:54:32.1607278Z    --- Ende der internen Ausnahmestapelüberwachung ---
  2017-01-30T08:54:32.1607278Z    bei System.Management.Automation.Runspaces.PipelineBase.Invoke(IEnumerable input)
  2017-01-30T08:54:32.1607278Z    bei System.Management.Automation.PowerShell.Worker.ConstructPipelineAndDoWork(Runspace rs, Boolean performSyncInvoke)
  2017-01-30T08:54:32.1607278Z    bei System.Management.Automation.PowerShell.Worker.CreateRunspaceIfNeededAndDoWork(Runspace rsToUse, Boolean isSync)
  2017-01-30T08:54:32.1607278Z    bei System.Management.Automation.PowerShell.CoreInvokeHelper[TInput,TOutput](PSDataCollection`1 input, PSDataCollection`1 output, PSInvocationSettings settings)
  2017-01-30T08:54:32.1607278Z    bei System.Management.Automation.PowerShell.CoreInvoke[TInput,TOutput](PSDataCollection`1 input, PSDataCollection`1 output, PSInvocationSettings settings)
  2017-01-30T08:54:32.1607278Z    bei Microsoft.TeamFoundation.DistributedTask.Handlers.LegacyVSTSPowerShellHost.VSTSPowerShellHost.Main(String[] args)
  2017-01-30T08:54:32.1763500Z ##[error]LegacyVSTSPowerShellHost.exe completed with return code: -1.
  2017-01-30T08:54:32.1763500Z ##[section]Finishing: Complete the SonarQube analysis
  </code></pre>
  
  <p>As the analysis finished, I assume this is some kind of logging done by SonarQube afterwards.</p>
  
  <p>Build Agent is installed on server A, SonarQube installed on server B. The "prepare step" Build Task finishes without errors so I assume, the basic SonarQube Setup is ok. I installed SonarQube 5.6.5 LTS and the Sonar User provided in the SonarQube.Analysis.xml is the default admin/admin user.</p>
  
  <p>Any suggestions?</p>