TFSLabConfig SetServiceAccount Command

Sets the service account credentials of a team project collection to the specified user in Visual Studio Team Foundation Server. The service account is added to the following team project collection groups:

  • Build Service - for deployment activities in the build agent and access to drop locations.

  • Test Service - for authorization of communication between test agents and test controllers.

The service account is used by test agents and build agents in a team project collection to communicate with test and build controllers.


The credentials of the service account are not secured in Team Foundation Server. The service account should be created with the minimum rights on the system. The SetServiceAccount command grants the specified user the permissions that are required to enable communication between agents and controllers.

Required Permissions

To use the SetServiceAccount command, you must have the Manage Lab Locations permission at the Team Project Collection Host Group level. By default, the members of the TFS Administrators and Project Collection Administrators groups have this permission. For more information, see Team Foundation Server Permissions.

TFSLabConfig SetServiceAccount




Required. The URL of the team project collection on the application-tier of Team Foundation Server to associate with the service account.


Required. The domain, if necessary, and user name of the service account.

The SetServiceAccount command replaces any existing service account credentials in the team project collection configuration. However, the credentials that are used in deployed environments are not replaced. Use the UpdateCredentialsOnDeployedEnvironments command to replace the credentials in existing environments.


For increased readability in the example, command options are listed on separate lines. In a command prompt window, type all options for a command on the same line.

This example adds a service account for a team project collection.


TFSLabConfig SetServiceAccount

Community Additions