whoami
Am a developer with the Lab Management team and work in the areas related to the setup and administration of the product. The intention is to publish out some random bits that could help other developers.
Since I don't want my first post to be a total dud I'm adding a slighlty modified version of jmanning's infamous get-tfs.ps1 script. This introduces you to our namespace and allows you to access the public lab services. There are only 3 new lines added in here. HTH for an appetizer.
param(
[string] $serverName = $(throw 'serverName is required')
)begin
{
# load the required dll
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.TeamFoundation.Client")
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.TeamFoundation.Lab.Client")$propertiesToAdd = (
('VCS', 'Microsoft.TeamFoundation.VersionControl.Client', 'Microsoft.TeamFoundation.VersionControl.Client.VersionControlServer'),
('WIT', 'Microsoft.TeamFoundation.WorkItemTracking.Client', 'Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItemStore'),
('CSS', 'Microsoft.TeamFoundation', 'Microsoft.TeamFoundation.Server.ICommonStructureService'),
('GSS', 'Microsoft.TeamFoundation', 'Microsoft.TeamFoundation.Server.IGroupSecurityService'),
('LS', 'Microsoft.TeamFoundation.Lab.Client', 'Microsoft.TeamFoundation.Lab.Client.LabService'),
('LAS', 'Microsoft.TeamFoundation.Lab.Client', 'Microsoft.TeamFoundation.Lab.Client.LabAdminService')
)
}process
{
# fetch the TFS instance, but add some useful properties to make life easier
# Make sure to "promote" it to a psobject now to make later modification easier
[psobject] $tfs = [Microsoft.TeamFoundation.Client.TeamFoundationServerFactory]::GetServer($serverName)
foreach ($entry in $propertiesToAdd) {
$scriptBlock = '
[System.Reflection.Assembly]::LoadWithPartialName("{0}") > $null
$this.GetService([{1}])
' -f $entry[1],$entry[2]
$tfs | add-member scriptproperty $entry[0] $ExecutionContext.InvokeCommand.NewScriptBlock($scriptBlock)
}
return $tfs
}