SRX
SRX

Reputation: 89

How to get list of current/active TFS users?

I can use TFSCONFIG IDENTITIES to see all users in TFS, however, that pulls up accounts that are years old and no longer have an AD account tied to it. I want to limit search to only people that have an AD account. Is this possible? I did find blog below, but before I try that I wanted to see if there was a powershell script or TFS command that would provide what I needed. thanks.

https://blogs.msdn.microsoft.com/tfssetup/2013/09/18/how-to-generate-a-report-of-active-users-who-log-onto-the-tfs-server/

Upvotes: 4

Views: 7090

Answers (3)

new2tech
new2tech

Reputation: 53

Try this utility/command:

tfssecurity /imx all: https://yourtfsserver.company.com

That should print out everything. If anything just look at the help for this tool. It tells you how to do exactly what you're asking for.

It would be in %INSTALL_DRIVE%\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE

Upvotes: 0

Zephan Schroeder
Zephan Schroeder

Reputation: 695

After reading this and couple related threads I found the following worked great for me (on TFS2015U3):

USE [Tfs_YourTeamProjectCollectionNameHere]  -- Optional if you already have Query connected to your TPC.
SELECT IdentityName AS [User], Max(StartTime) AS [LastConnect] FROM tbl_Command with (nolock) GROUP BY IdentityName ORDER BY [LastConnect] DESC

Last Login for each user - per www.databaseforum.info/30/1174675.aspx (likely scraped from some other original source) and legit reference "What's My Server Doing?" https://blogs.msdn.microsoft.com/jefflu/2005/08/11/team-foundation-whats-my-server-doing/

Cheers and enjoy! -Zephan

Upvotes: 0

PatrickLu-MSFT
PatrickLu-MSFT

Reputation: 51073

There is no such TFS command line could handle this situation. Afraid you have to go through the collection database level in TFS to obtain related info.

You could use Last_Access_Time, a sample script as below:

SELECT IdentityName,
StartTime,
Command,
IPAddress,
ExecutionTime
FROM tbl_Command WHERE CommandId IN
(SELECT Max(CommandId) FROM tbl_Command WHERE Application NOT LIKE 'Team Foundation JobAgent' Group By IdentityName ) ORDER BY Last_Access_Time DESC

Note, before you run the SQL script, you could double check if there are something changed, if there are some columns not available any more, since the blog is out of date.


Another way is archiving the contents of the tbl_command in the TFS databases. In the TFS databases tbl_command captures connection information. This table by default only stores 14 days of information. You could take a look at this similar question: Find out the users that has logged-in to TFS in last 6 months

You could setup another database and have a job to copy information for longer term use. Details please refer this sample.

Upvotes: 1

Related Questions