How to find test points assigned to a particular person

Here is a code snippet which you can use to find test points assigned to a particular person.

# Load Client Assembly
[Reflection.Assembly]::Load(“Microsoft.TeamFoundation.Client, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a”);
[Reflection.Assembly]::Load(“Microsoft.TeamFoundation.TestManagement.Client, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a”);
[Reflection.Assembly]::Load(“Microsoft.TeamFoundation.TestManagement.Common, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a”);

 
# Define parameters
$tfsCollectionUrl = “ https://myserver:8080/tfs/DefaultCollection”;
$projectName = "DefaultProject";
$planId = "1";
$userDisplayName = "Aseem Bansal";

# Connect to tfs
$tfsCollection = [Microsoft.TeamFoundation.Client.TfsTeamProjectCollectionFactory]::GetTeamProjectCollection($tfsCollectionUrl);
$tcmService = $tfsCollection.GetService([Microsoft.TeamFoundation.TestManagement.Client.ITestManagementService]);
[Microsoft.TeamFoundation.TestManagement.Client.ITestManagementTeamProject] $tcmProject = $tcmService.GetTeamProject($projectName);
$identityStore = $tcmProject.TfsIdentityStore;

# Find the identity
$identity = $identityStore.FindByDisplayName($userDisplayName);
$identityId = $identity.TeamFoundationId;

# Query for test plan/points
$testPlansProperty = [Microsoft.TeamFoundation.TestManagement.Client.ITestManagementTeamProject].GetProperty("TestPlans").GetGetMethod();
$testPlans = $testPlansProperty.Invoke($tcmProject, "instance,public", $null, $null, $null);
$testPlan = $testPlans.Find($planId);
$query = "SELECT * FROM TestPoint WHERE AssignedTo='" + $identityId + "'";
$testPoints = $testPlan.QueryTestPoints($query);

Write-Host ” ================================ “
Write-Host “Testpoints: “$testPoints