In CSS we regularly use a variety of command line tools for troubleshooting and maintenance of Team Foundation Server (TFS) and related technologies. This post provides a grouping of the most frequently used command which TFS administrators should keep handy with them. We do look forward to feedback from the community to add more command line tools to this list over a period of time.

This post lists the commands which we use most frequently use for Team Foundation Server, SharePoint and Reporting services.

Team Foundation Server Commands:

Accounts Command:

We can use the Accounts command to change the service accounts and passwords that Team Foundation Server use. In general, we use this command to change, update or modify an account under which the Team Foundation Server services will run. For instance, the password for TFSService was modified in Active Directory and found that TFS services are not running. Then we need to use this command to update the password for the account TFSService. In TFS2010, the accounts and passwords can be updated using Team Foundation Administration Console.

Required Permissions:

To use the Accounts Command you must be the part of the Team Foundation Server Administrators security group and “sysadmin”security group on the SQL server databases which the team foundation server is using. If you use “/Proxy” option, then you should be the member of the Administrator group on the proxy server.

Syntax:

TFSConfig Accounts /change|add|set|delete|updatepassword|resetowner [/AccountType:{ApplicationTier|ReportingDataSource|Proxy}] [/Account:AccountName] [/Password:Password] [/SQLInstance:ServerName] [/DatabaseName:DatabaseName] [/Continue]

Example

The following example shows how to change the service account of data sources for Reporting Services to a new account in the “Production domain”, “Production\NewAccount”, and the password, to Password.3

TFSConfig Accounts /change /AccountType:ReportingDataSource /Account:Production\NewAccount /Password:Password3

For detail information about the Accounts command, refer the following link on MSDN.

http://msdn.microsoft.com/en-us/library/ms253107.aspx

Identities Command

We can use the identities command to list or change the security identifiers (SID) of users and groups in your deployment of Team Foundation server. For instance, to move the Team Foundation Server from workgroup to a domain, we need to move the users from local system to the domain first; otherwise, the user names will be displayed as unknown for work items. Use identities command in below scenarios:

· changing from a workgroup to a domain or from a domain to a workgroup

· migrating accounts across domains in Active Directory

· restoring a deployment to new hardware but still want to keep the original deployment operational (a process that is referred to as cloning the server)

Required Permissions

To use this command, you must be the member of the Team Foundation Administrator group on the application tier and sysadmin group of SQLServer on which TFS Data tier was configured. If a software update mismatch occurs, you can use this command to identify the problem and receive information about what additional steps you must take to address the issues.

TFSConfig Identities [/change /fromdomain:DomainName1 /todomain:DomainName2 [/account:AccountName] [/toaccount:AccountName]] [/sqlInstance:ServerName /databaseName:DatabaseName] [/account:AccountName]

TFSConfig Identities

The following example shows how to change the SIDs for all accounts in Team Foundation Server from the Contoso1 domain to the SIDs for accounts that have matching names in the ContosoPrime domain. Only account names that match will have their SIDs updated. For example, if the "hholt" account exists as Contoso1\hholt and ContosoPrime\hholt, the account SID will be changed to the SID for ContosoPrime\hholt. If the "ContosoPrime\hholt" account does not exist, the SID will not be updated for Contoso1\hholt.

TFSConfig Identities /change /fromdomain:Contoso1 /todomain:ContosoPrime

For more information please

http://msdn.microsoft.com/en-us/library/ms253054.aspx

 

PrepSQL

Use this command, if you want to create a SQL instance to host the Team Foundation databases. In general, we use this command during Team Foundation server hardware move to prepare your SQL Server deployment.

Required Permission:

To use the PrepSQL command, you must be a member of the Team Foundation Administrators security group and a member of the sysadmin security group for any SQL Server databases that Team Foundation Server uses.

TFSConfig PrepSQL /SQLInstance:ServerName[\InstanceName]

Example:

The following example shows how to prepare a server that is running SQL Server and that is named ContosoMain on the named instance TeamDatabases to host databases for Team Foundation Server.

TFSConfig PrepSQL /SQLInstance:ContosoMain\TeamDatabases

For more information please refer the below MSDN link

http://msdn.microsoft.com/en-us/library/ee349267.aspx

Rebuild Warehouse

We use the RebuildWarehouse command when the Team Foundation Reports shows warehouse processing errors. This command deletes the warehouse & analysis databases and rebuilds the databases. In TFS2010, we can rebuild the warehouse from the Team Foundation Administration console.

Required Permission:

To use the RebuildWarehouse command, you must be a member of the following groups:

· the Team Foundation Administrators security group and the Administrators security group on the server or servers that are running the administration console for Team Foundation

· the sysadmin group on the server or servers that are running the instance of SQL Server that hosts the databases for Team Foundation Server

TFSConfig RebuildWarehouse /analysisServices | /all [/ReportingDataSourcePassword:Password]

Example:

The following example shows how to rebuild the Analysis Services database for a deployment of Team Foundation Server

TFSConfig RebuildWarehouse /analysisServices /all

For more information please refer the below link

http://msdn.microsoft.com/en-us/library/ee349264.aspx

RegisterDB

This command is useful if you move the configuration database to a new hardware. If you have more than one application tier, you should run this command on all the application tiers. This command

Required Permissions:

To use the RegisterDB command, you must be a member of the Team Foundation Administrators group on the application-tier server for Team Foundation and a member of the sysadmin group in SQL Server on the data-tier server for Team Foundation.

TFSConfig RegisterDB /SQLInstance:ServerName

Example:

The following example redirects Team Foundation Server to a configuration database that is located on the server ContosoMain in the SQL Server instance TeamDatabases.

TFSConfig RegisterDB /SQLInstance:ContosoMain\TeamDatabases

For more information about this command, refer the below MSDN link

http://msdn.microsoft.com/en-us/library/ms252443.aspx

 

RemapDBs Command

We use this command when your Team Foundation server databases are hosted in different servers. For instance, you have configuration database hosted on one server and Team project collection database hosted on separate server then we must use the RemapDbs command to redirect the team foundation server to its databases.

Required Permissions

To use the RemapDBs command, you must be a member of the Team Foundation Administrators security group and a member of the sysadmin security group for any SQL Server databases that Team Foundation Server uses

TFSConfig RemapDBs /DatabaseName:ServerName;DatabaseName /SQLInstances:ServerName1,ServerName2 [/AnalysisInstance:ServerName] [/AnalysisDatabaseName:DatabaseName] [/preview] [/continue]

Example:

The following example shows how to redirect Team Foundation Server to its configuration database TFS_Configuration. This database is hosted on ContosoMain on the named instance TeamDatabases. Its project collection databases are stored on both ContosoMain\TeamDatabases and the default instance on Contoso2.

TFSConfig RemapDBs /DatabaseName:ContosoMain\TeamDatabases;TFS_Configuration /SQLInstances:ContosoMain\TeamDatabases,Contoso2

For more information please refer the below link

http://msdn.microsoft.com/en-us/library/ee349262.aspx

ChangeServerId Command

This command is used to change the Global unique Identifiers (GUIDs) that are associated with the databases for Team foundation Server. We use this command in below scenarios:

- When Team Foundation server deployment was restored to new hardware, the old deployment is still operational and you want to use both deployments.

- When you want to test a software update or a hardware configuration on a duplicate deployment, so that you do not want to disrupt your production environment

- When you want to test the restoration of databases to new hardware in a test environment to ensure that your deployment can be restored.

- When you move a collection database to another deployment for which that GUID is already reserved.

Required Permissions:

To use this command, one should be the member of Team Foundation Server Administrator security group and should be part of sysadmin group of any SQL Server databases that TFS uses.

TFSConfig ChangeServerID /SQLInstance:ServerName] /DatabaseName:ConfigurationDatabaseName [/ProjectCollectionsOnly] [/ConfigDBOnly]

Example:

The following example shows how to change the GUIDs of all databases in the Contoso1 deployment of Team Foundation Server, where the configuration database is hosted on the server that is named "ContosoMain" on the named instance "TeamDatabases" in SQL Server

TFSConfig ChangeServerID /SQLInstance:ContosoMain\TeamDatabases /DatabaseName:TFS_ConfigurationDB

For more information, please go through the below link

http://msdn.microsoft.com/en-us/library/ee349259.aspx

TFS Security

You can use the TFSSecurity command-line utility to create, modify, and delete groups and users in Visual Studio Team Foundation Server, in addition to modifying permissions for groups and users.

/i : use /i to display the identity information for a specified group in a deployment of Team Foundation server.

Required permissions:

To use the /i command, you must have the View Collection Level Information Or the View system Level information permission to set to Allow.

TFSSecurity /i Identity [/Collection:CollectionURL][/server:ServerURL]

TfsSecurity /imx

Use /imx to display information about the identities that compose the expanded membership of a specified group.

TFSSecurity /imx Identity [/collection:CollectionURL] [/server:ServerURL]

Tfssecurity /g+

Use /g+ to add a user or a group to an existing group.

Required permission:

To use the /g+ command, you must have the View collection-level information and Edit collection-level information or the View instance-level information and Edit instance-level information permissions set to Allow, depending on whether you are using the /collection or /server parameter, respectively

TFSSecurity /g+ groupIdentity memberIdentity [/collection:CollectionURL] [/server:ServerURL]

Example:

The following example adds the Testenv domain user John Peoples (Testenv\jpeoples) to the Team Foundation Administrators group.

>tfssecurity /g+ "Team Foundation Administrators" n:testenv\jpeoples ALLOW /server:http://Testenvsys:8080

Tfssecurity /g-

Use /g- to remove a user or a user group from an existing group.

Required Permissions

To use the /g- command, you must have the View collection-level information and Edit collection-level information or the View instance-level information and Edit instance-level information permissions set to Allow, depending on whether you are using the /collection or /server parameter, respectively.

TFSSecurity /g- groupIdentity memberIdentity [/server:CollectionURL] [/instance:ServerURL]

Example

The following example removes the Testenv domain user John Peoples (Testenv\jpeoples) from the Team Foundation Administrators group

>tfssecurity /g- "Team Foundation Administrators" n:Datum1\jpeoples ALLOW /server:http://Testenv:8080

TFSDeleteproject:

You can remove a Team Project from a collection when you no longer required by using TFSDeleteproject. You can also delete a Team project when an unknown error was occurred under a team project collection. You can find the TFSDeleteProject command line tool in Drive:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE on any client computer that runs Team Explorer.

Also, you can delete a Team project from the TFS2010 Administration console.

Required Permissions:

To delete a Team Project, you must be the member of the Team Foundation Administrator group or Project Administrators group.

Syntax:

TFSDeleteproject [/q] [/force] [/excludewss] /collection:URL TeamProjectName

Please refer the below link for detail information

http://msdn.microsoft.com/en-US/library/ms181482(v=VS.100).aspx

 

RSKeymgmt utility in SQL Server 2008:

The Rskeymgmt tool is used to manage the symmetric keys used by report server. This tool captures the complete key set that is defined during setup, and stores it as a file that you can store externally. You can use this tool to backup, change or apply the key. If the tool does not recover the key, you can delete the encrypted content. This utility is also used to join the report server instances in the scale out deployment. The Report server scale out deployment refers to multiple report server instances that share a single report server database.

Permissions:

You must be the local administrator to run the utility and you must run the tool on the local system. You cannot run this tool to manage the encryption keys on the remote report server instance.

RsKeymgmt –l

We use this command to list the Reporting server installation instances on the system

Rskeymgmt –r instanceid

We use this command to delete an existing Report server instance

Syntax:

Rskeymgmt –r instanceid

We generally use these commands during Team Foundation server moves and you want to restore the Report Server databases on a specific instance.

Rskeymgmt –e

This command is used to extract the symmetric key used to encrypt and decrypt data for report server instance so that you can copy it to a file.

The following example shows how to create a backup copy of the encryption key and save it to a password protected file.

Rskeymgmt –e –f c:\backup\keys –p <password>

Rskeymgmt –a

This command replaces an existing symmetric key with a copy that you provide in a password protected file. We use this command more often in Team Foundation hardware based move.

This example shows how to replace the encryption key. You must specify the location of the backup copy of the key and the password that unlocks the key.

Rskeymgmt –a –f c:\backup\keys –p<password>

Rskeymgmt –d

This command deletes all symmetric key values and encrypted data in a Report Server database.

While browsing the Reports Manager URL (http://localhost/Reports) sometimes an error “Reporting services are not initialized or services are not running”. To resolve this issue, we should restore the encryption key. If encryption key is not available, delete the encrypted content

This example shows how to delete the encryption keys and encrypted data. If your installation is a report server scale out deployment, the encryption keys in all the report server databases will be deleted. This command takes no arguments.

Rskeymgmt –d

 

STSAdm Commands:

Retractsolution

This command Retracts the specified solution’s deployment. The retractsolution operation removes files from the front-end Web server. The deletesolution operation deletes the solution package in the solution store of the configuration, and should only be called after solution packages have been retracted

stsadm -o retractsolution -name <Solution name> [-url <virtual server url>] [-allcontenturls] [-time <time to remove at>] [-immediate] [-local] [-lcid <language>]

Database

AddContentDB

This command is used to add an existing content database when upgraded from previous version database. We use this command during Team Foundation server upgrade

Syntax:

stsadm -o addcontentdb -url <url> -databasename <database name> [-databaseserver <database server name>] [-databaseuser <database username>] [-databasepassword <database password>] [-sitewarning <site warning count>] [-sitemax <site max count>] DatabaseRepair

Example:

Stsadm –o addcontentdb –url “http://servername” –databasename “WSS_Content”

DeleteContentDB

This Command is used to detach a SharePoint Content database. We use this command when you want to move your SharePoint to a new location.

Syntax:

stsadm -o deletecontentdb -url <url> -databasename <database name> [-databaseserver <database server name>]

Example:

Stsadm –o deletecontentdb –url “http://servername:portno/sites/defaultCollection” -databasename “WSS_Contentdb”

addpermissionpolicy

This command is used to change the permission policy of the content database so that the Team Foundation Server accesses the content database.

stsadm.exe -o addpermissionpolicy -url http://SharePointServerName -userlogin DomainName\UserName -permissionlevel "full control"

enumtemplates

This command is used to list all the site templates that are submitted in the global template catalog. We have CMMI and Agile templates in TFS under which we create the Team Projects. Run this command whether these templates are available in global template catalog. If these are not available, install the extensions for SharePoint and configure.

Stsadm.exe –o enumtemplates

Add solution

This command is used to add the solution to the SharePoint solutions store

stsadm.exe" -o addsolution -filename <filename> [-lcid] <language>

Example:

stsadm.exe -o addsolution -filename "c:\Program Files\Microsoft Team Foundation Server 2010\Tools\Templates\Microsoft.TeamFoundation.SharePoint.wsp”

 

Deploy solution:

Deploys files related to a solution from the configuration database to individual front-end Web servers in the farm

Syntax:

stsadm -o deploysolution -name <solution name>[-url] <virtual server URL>[-allcontenturls][-time] <time to deploy> [-immediate][-local][-allowgacdeployment][-allowcaspolicies][-lcid] <language>

[-force]

Example:

stsadm.exe" -o deploysolution -name Microsoft.TeamFoundation.SharePoint.wsp -local -force

Execadmsvcjobs

Executes all administrative timer jobs immediately instead of waiting for the timer job to run. We use this command after deploying the solutions to the SharePoint solution store. This command doesn’t take any parameters.

stsadm -o execadmsvcjobs

 

Content Developed By: Chandra Sekhar Viswanadha

Reviewed By: Lakhminder Singh