title: Cannot register a build agent in VSTS
body: <p>I am trying to register a build agent with VSTS by following the instructions <a href="https://www.visualstudio.com/en-us/docs/build/actions/agents/v2-windows" rel="noreferrer">here</a>. I created a PAT token in my Security settings and used it to register the agent. I used the following PS command to register the agent:</p>
  
  <pre><code>PS&gt;.\config.cmd --url 'https://[account].visualstudio.com/' --auth 'PAT' --token '[Token]' --pool '[Pool Name]' --agent '[Agent Name]'
  </code></pre>
  
  <p>I get the following information on the output:</p>
  
  <pre><code>&gt;&gt; Connect:
  
  Connecting to server ...
  
  &gt;&gt; Register Agent:
  
  Scanning for tool capabilities.
  Connecting to the server.
  Successfully added the agent
  Testing agent connection.
  </code></pre>
  
  <p>But it then gets stuck on this step and never completes. When I look at the agent pool in VSTS I see the new agent, but it's state is 'Offline'.</p>
  
  <p>I looked in the <code>_diag</code> folder and checked the latest log. There is an error there:</p>
  
  <pre><code>[2017-07-11 12:32:10Z WARN VisualStudioServices] Authentication failed with status code 401.
  Date: Tue, 11 Jul 2017 12:32:10 GMT
  P3P: CP="CAO DSP COR ADMa DEV CONo TELo CUR PSA PSD TAI IVDo OUR SAMi BUS DEM NAV STA UNI COM INT PHY ONL FIN PUR LOC CNT"
  Server: Microsoft-IIS/10.0
  WWW-Authenticate: Bearer authorization_uri=https://login.microsoftonline.com/b8f712c7-d223-4cfb-b165-6267fc789086, Basic realm="https://tfsprodweu2.app.visualstudio.com/", TFS-Federated
  X-TFS-ProcessId: f4c5d148-0e01-488f-ab27-69c753e38911
  Strict-Transport-Security: max-age=31536000; includeSubDomains
  ActivityId: b85558aa-d41a-4763-a311-f2498ddb2dc0
  X-TFS-Session: 8242b35d-d5e9-4242-8f52-b7c1f14c451c
  X-VSS-E2EID: 6494b165-d486-4064-a5fd-92ae7f201867
  X-FRAME-OPTIONS: SAMEORIGIN
  X-TFS-FedAuthRealm: https://tfsprodweu2.app.visualstudio.com/
  X-TFS-FedAuthIssuer: https://rr-ffes.visualstudio.com/
  X-VSS-ResourceTenant: b8f712c7-d223-4cfb-b165-6267fc789086
  X-TFS-SoapException: %3C%3Fxml%20version%3D%221.0%22%20encoding%3D%22utf-8%22%3F%3E%3Csoap%3AEnvelope%20xmlns%3Asoap%3D%22http%3A%2F%2Fwww.w3.org%2F2003%2F05%2Fsoap-envelope%22%3E%3Csoap%3ABody%3E%3Csoap%3AFault%3E%3Csoap%3ACode%3E%3Csoap%3AValue%3Esoap%3AReceiver%3C%2Fsoap%3AValue%3E%3Csoap%3ASubcode%3E%3Csoap%3AValue%3EUnauthorizedRequestException%3C%2Fsoap%3AValue%3E%3C%2Fsoap%3ASubcode%3E%3C%2Fsoap%3ACode%3E%3Csoap%3AReason%3E%3Csoap%3AText%20xml%3Alang%3D%22en%22%3ETF400813%3A%20Resource%20not%20available%20for%20anonymous%20access.%20Client%20authentication%20required.%3C%2Fsoap%3AText%3E%3C%2Fsoap%3AReason%3E%3C%2Fsoap%3AFault%3E%3C%2Fsoap%3ABody%3E%3C%2Fsoap%3AEnvelope%3E
  X-TFS-ServiceError: TF400813%3A%20Resource%20not%20available%20for%20anonymous%20access.%20Client%20authentication%20required.
  X-VSS-S2STargetService: 00000002-0000-8888-8000-000000000000/visualstudio.com
  X-TFS-FedAuthRedirect: https://app.vssps.visualstudio.com/_signin?realm=rr-ffes.visualstudio.com&amp;reply_to=https%3A%2F%2Frr-ffes.visualstudio.com%2F_apis%2FconnectionData%3FconnectOptions%3D1%26lastChangeId%3D-1%26lastChangeId64%3D-1&amp;redirect=1&amp;context=eyJodCI6MiwiaGlkIjoiNDEzNzE0YzItZWQ2OS00MWRkLWJmMTItNzc0ZTI1ZGEzOTdmIiwicXMiOnt9LCJyciI6IiIsInZoIjoiIiwiY3YiOiIiLCJjcyI6IiJ90#ctx=eyJTaWduSW5Db29raWVEb21haW5zIjpbImh0dHBzOi8vbG9naW4ubWljcm9zb2Z0b25saW5lLmNvbSIsImh0dHBzOi8vbG9naW4ubWljcm9zb2Z0b25saW5lLmNvbSJdfQ2
  X-Powered-By: ASP.NET
  X-Content-Type-Options: nosniff
  </code></pre>
  
  <p>I am sure I correctly entered the PAT access token, so what is the problem?</p>