How to get list of current/active TFS users?

拟墨画扇 提交于 2019-12-11 00:33:07

问题


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/


回答1:


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.




回答2:


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



来源:https://stackoverflow.com/questions/48586124/how-to-get-list-of-current-active-tfs-users

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!