Exception:
Exception calling "QueryActiveRequests" with "2" argument(s): "Value cannot be null.
Parameter name: second"
At C:\Builds\Service.ps1:2 char:30
+ $tfsadmin.QueryActiveRequests <<<< ($null, "False") | %{ $_.ActiveRequests } | ft StartTime,UserName,MethodName,RemoteComputer
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodException
Explanation:
The following powershell script to monitor the TFS active requests work on TFS 2010 but fails with the above exception on TFS 2012.
$tfsadmin = New-WebServiceProxy –UseDefaultCredential -URI http://tfs:8080/tfs/TeamFoundation/administration/v3.0/AdministrationService.asmx?WSDL
$tfsadmin.QueryActiveRequests($null, "False") | %{ $_.ActiveRequests } | ft StartTime,UserName,MethodName,RemoteComputer
While accessing TFS 2012 server, the QueryActiveRequests web method fails to accept null value as an argument.
Workaround:
The workaround is to pass the TFS 2012 HostId as first parameter instead of $null
Following are the step to find the TFS host id
1. Open Microsoft SQL Server Management Studio
2. Connect to TFS 2012 data tier
3. Execute the below query
USE [Tfs_Configuration]
SELECT [HostId], [Name] FROM [Tfs_Configuration].[dbo].[tbl_ServiceHost] where [Name] = 'TEAM FOUNDATION'
Result
-------
HostId Name
AAAAAAAA-96A2-4BA8-A74C-11422B123456 TEAM FOUNDATION
4. Replace $null with the HostId
$tfsadmin = New-WebServiceProxy –UseDefaultCredential -URI http://tfs:8080/tfs/TeamFoundation/administration/v3.0/AdministrationService.asmx?WSDL
$tfsadmin.QueryActiveRequests("AAAAAAAA-96A2-4BA8-A74C-11422B123456","False") | %{ $_.ActiveRequests } | sort StartTime | ft StartTime,UserName,MethodName,RemoteComputer