TfsCmdlets.Types.ps1xml

<?xml version="1.0" encoding="utf-8"?>
<Types>
  <Type>
    <Name>Microsoft.TeamFoundation.Build.WebApi.BuildDefinitionReference</Name>
    <Members>
      <ScriptProperty>
        <Name>QueueName</Name>
        <GetScriptBlock>$this.Queue.Name</GetScriptBlock>
      </ScriptProperty>
      <ScriptProperty>
        <Name>PoolName</Name>
        <GetScriptBlock>$this.Queue.Pool.Name</GetScriptBlock>
      </ScriptProperty>
      <ScriptProperty>
        <Name>IsHostedPool</Name>
        <GetScriptBlock>$this.Queue.Pool.IsHosted</GetScriptBlock>
      </ScriptProperty>
      <ScriptProperty>
        <Name>TeamProject</Name>
        <GetScriptBlock>$this.Project.Name</GetScriptBlock>
      </ScriptProperty>
    </Members>
  </Type>
  <Type>
    <Name>Microsoft.TeamFoundation.Build.WebApi.Folder</Name>
    <Members>
      <ScriptProperty>
        <Name>Name</Name>
        <GetScriptBlock>if($this.Path -eq '\') { '\' } else { $this.Path.Substring($this.Path.LastIndexOf('\')+1) }</GetScriptBlock>
      </ScriptProperty>
    </Members>
  </Type>
  <Type>
    <Name>Microsoft.TeamFoundation.Client.BuildController</Name>
    <Members>
      <ScriptProperty>
        <Name>Collection</Name>
        <GetScriptBlock>$this.BuildServer.TeamProjectCollection.Name</GetScriptBlock>
      </ScriptProperty>
    </Members>
  </Type>
  <Type>
    <Name>Microsoft.TeamFoundation.Client.TeamFoundationTeam</Name>
    <Members>
      <ScriptProperty>
        <Name>IsDefault</Name>
        <GetScriptBlock>try
    {
    $tpcId = $this.GetProperty('SecuringHostId')
    $tpId = $this.Project
 
    if ($TfsTpcConnection -and ($TfsTpcConnection.InstanceId -eq $tpcId))
    {
    $tpc = $TfsTpcConnection
    }
    else
    {
    $tpc = Get-TfsTeamProjectCollection | Where-Object InstanceId -eq $tpcId
    }
    $teamService = $tpc.GetService([type]'Microsoft.TeamFoundation.Client.TfsTeamService')
    return ($teamService.GetDefaultTeamId("$tpId") -eq $this.Identity.TeamFoundationId)
    }
    catch
    {
    return $null
    }</GetScriptBlock>
      </ScriptProperty>
      <ScriptProperty>
        <Name>Id</Name>
        <GetScriptBlock>$this.Identity.TeamFoundationId</GetScriptBlock>
      </ScriptProperty>
    </Members>
  </Type>
  <Type>
    <Name>Microsoft.TeamFoundation.Client.TfsConfigurationServer</Name>
    <Members>
      <ScriptProperty>
        <Name>Name</Name>
        <GetScriptBlock>$this.Uri.Host</GetScriptBlock>
      </ScriptProperty>
    </Members>
  </Type>
  <Type>
    <Name>Microsoft.TeamFoundation.Client.TfsTeamProjectCollection</Name>
    <Members>
      <ScriptProperty>
        <Name>Name</Name>
        <GetScriptBlock>$this.CatalogNode.Resource.DisplayName</GetScriptBlock>
      </ScriptProperty>
      <ScriptProperty>
        <Name>InstanceId</Name>
        <GetScriptBlock>$this.CatalogNode.Resource.Properties["InstanceId"]</GetScriptBlock>
      </ScriptProperty>
    </Members>
  </Type>
  <Type>
    <Name>Microsoft.TeamFoundation.Core.WebApi.Process</Name>
    <Members>
      <ScriptProperty>
        <Name>Collection</Name>
        <GetScriptBlock>return ((($this.Url -split '/_apis/')[0]) -split '/')[-1]</GetScriptBlock>
      </ScriptProperty>
    </Members>
  </Type>
  <Type>
    <Name>Microsoft.TeamFoundation.Core.WebApi.TeamProject</Name>
    <Members>
      <ScriptProperty>
        <Name>ProcessTemplate</Name>
        <GetScriptBlock>if($this.Capabilities) {$this.Capabilities.processTemplate.templateName} else {'(N/A)'}</GetScriptBlock>
      </ScriptProperty>
      <ScriptProperty>
        <Name>Properties</Name>
        <GetScriptBlock>if($this.Capabilities) {
    [TfsCmdlets.Util.LazyProperty]::Get($this, 'Properties', {
    $projectClient = Get-TfsRestClient 'Microsoft.TeamFoundation.Core.WebApi.ProjectHttpClient'
    $props = $projectClient.GetProjectPropertiesAsync($_.Id).Result
    $val = @{}
    $props | % { $val.Add($_.Name, $_.Value) }
    return $val })
} else {
    $null
}
</GetScriptBlock>
      </ScriptProperty>
    </Members>
  </Type>
  <Type>
    <Name>Microsoft.TeamFoundation.Core.WebApi.WebApiTagDefinition</Name>
    <Members>
      <ScriptProperty>
        <Name>Project</Name>
        <GetScriptBlock>return [TfsCmdlets.Util.LazyProperty]::Get($this, 'Project', {
    $tp = Get-TfsTeamProject ([uri]$_.Url).Segments[-3].TrimEnd("/")
    return $tp.Name
})
</GetScriptBlock>
      </ScriptProperty>
    </Members>
  </Type>
  <Type>
    <Name>Microsoft.TeamFoundation.Policy.WebApi.PolicyConfiguration</Name>
    <Members>
      <ScriptProperty>
        <Name>Project</Name>
        <GetScriptBlock>return [TfsCmdlets.Util.LazyProperty]::Get($this, 'TeamProject', {
    return (Get-TfsTeamProject -Project $this.ProjectId).Name
})
</GetScriptBlock>
      </ScriptProperty>
      <ScriptProperty>
        <Name>Repository</Name>
        <GetScriptBlock>return [TfsCmdlets.Util.LazyProperty]::Get($this, 'Repository', {
    return (Get-TfsGitRepository -Repository $this.RepositoryId -Project $this.ProjectId).Name
})
</GetScriptBlock>
      </ScriptProperty>
      <ScriptProperty>
        <Name>PolicySettings</Name>
        <GetScriptBlock>return [TfsCmdlets.Util.LazyProperty]::Get($this, 'PolicySettings', {
    return $_.Settings.ToString() | ConvertFrom-Json
})
</GetScriptBlock>
      </ScriptProperty>
      <ScriptProperty>
        <Name>RepositoryId</Name>
        <GetScriptBlock>$this.PolicySettings.scope[0].repositoryId</GetScriptBlock>
      </ScriptProperty>
      <ScriptProperty>
        <Name>ProjectId</Name>
        <GetScriptBlock>([uri] $this.Url).Segments[-5].TrimEnd('/')</GetScriptBlock>
      </ScriptProperty>
      <ScriptProperty>
        <Name>Branch</Name>
        <GetScriptBlock>$this.PolicySettings.scope[0].refName.SubString(11)</GetScriptBlock>
      </ScriptProperty>
      <ScriptProperty>
        <Name>RefName</Name>
        <GetScriptBlock>$this.PolicySettings.scope[0].refName</GetScriptBlock>
      </ScriptProperty>
      <ScriptProperty>
        <Name>DisplayName</Name>
        <GetScriptBlock>$this.Type.DisplayName</GetScriptBlock>
      </ScriptProperty>
      <ScriptProperty>
        <Name>BuildDefinition</Name>
        <GetScriptBlock>if ($this.Type.DisplayName -ne 'Build') { return }
 
return [TfsCmdlets.Util.LazyProperty]::Get($this, 'BuildDefinition', {
    $url = $_.Url.Substring(0, $_.Url.IndexOf('/policy/configurations'))
    $url = "$url/build/definitions/$($_.PolicySettings.buildDefinitionId)"
    return (Invoke-TfsRestApi $url).name
})
</GetScriptBlock>
      </ScriptProperty>
    </Members>
  </Type>
  <Type>
    <Name>Microsoft.TeamFoundation.Server.NodeInfo</Name>
    <Members>
      <ScriptProperty>
        <Name>NodeType</Name>
        <GetScriptBlock>switch($this.StructureType)
    {
    'ProjectModelHierarchy' { return 'Area' }
    'ProjectLifecycle' { return 'Iteration' }
    default { return "(Unknown: $($this.StructureType))" }
    }</GetScriptBlock>
      </ScriptProperty>
      <ScriptProperty>
        <Name>TeamProject</Name>
        <GetScriptBlock>$this.Path.Substring(1, $this.Path.IndexOf('\', 2)-1)</GetScriptBlock>
      </ScriptProperty>
      <ScriptProperty>
        <Name>FullPath</Name>
        <GetScriptBlock>$this.Path.Substring(0, $this.Path.IndexOf('\', 2))+$this.Path.Substring($this.Path.IndexOf('\',$this.Path.Substring(0, $this.Path.IndexOf('\',1)+1).Length))</GetScriptBlock>
      </ScriptProperty>
      <ScriptProperty>
        <Name>RelativePath</Name>
        <GetScriptBlock>$this.Path.Substring($this.Path.IndexOf('\',$this.Path.Substring(0, $this.Path.IndexOf('\',1)+1).Length))</GetScriptBlock>
      </ScriptProperty>
      <ScriptProperty>
        <Name>Id</Name>
        <GetScriptBlock>$this.Uri.Substring($this.Uri.LastIndexOf('/')+1)</GetScriptBlock>
      </ScriptProperty>
    </Members>
  </Type>
  <Type>
    <Name>Microsoft.TeamFoundation.SourceControl.WebApi.GitBranchStats</Name>
    <Members>
      <ScriptProperty>
        <Name>Project</Name>
        <GetScriptBlock>return [TfsCmdlets.Util.LazyProperty]::Get($this, 'TeamProject', {
    $url = [uri] $_.Commit.Url.SubString(0, $_.Commit.Url.IndexOf('/commits/'))
    $path = $url.PathAndQuery.Substring($url.Segments[1].Length)
    $repo = Invoke-TfsRestApi $path
    return $repo.project.Name
})
</GetScriptBlock>
      </ScriptProperty>
      <ScriptProperty>
        <Name>Repository</Name>
        <GetScriptBlock>return [TfsCmdlets.Util.LazyProperty]::Get($this, 'Repository', {
    $url = [uri] $_.Commit.Url.SubString(0, $_.Commit.Url.IndexOf('/commits/'))
    $path = $url.PathAndQuery.Substring($url.Segments[1].Length)
    $repo = Invoke-TfsRestApi $path
    return $repo.Name
})
</GetScriptBlock>
      </ScriptProperty>
    </Members>
  </Type>
  <Type>
    <Name>Microsoft.TeamFoundation.SourceControl.WebApi.GitItem</Name>
    <Members>
      <ScriptProperty>
        <Name>Folder</Name>
        <GetScriptBlock>if($this.Path -eq '/' -or ($this.Path.LastIndexOf('/') -eq 0)) { '/' } else { $this.Path.Substring(1, $this.Path.LastIndexOf('/')-1) }
</GetScriptBlock>
      </ScriptProperty>
    </Members>
  </Type>
  <Type>
    <Name>Microsoft.TeamFoundation.SourceControl.WebApi.GitRepository</Name>
    <Members>
      <ScriptProperty>
        <Name>TeamProject</Name>
        <GetScriptBlock>$this.ProjectReference.Name</GetScriptBlock>
      </ScriptProperty>
    </Members>
  </Type>
  <Type>
    <Name>Microsoft.TeamFoundation.Work.WebApi.BoardCardRuleSettings</Name>
    <Members>
      <ScriptProperty>
        <Name>Board</Name>
        <GetScriptBlock>([uri] $this.Links.Links.board.Href).Segments[-1]</GetScriptBlock>
      </ScriptProperty>
      <ScriptProperty>
        <Name>Team</Name>
        <GetScriptBlock>return [TfsCmdlets.Util.LazyProperty]::Get($this, 'Team', {
    $u = [uri] $_.Links.Links.board.Href
    $teamId = $u.Segments[-5].TrimEnd('/')
    $projId = $u.Segments[-6].TrimEnd('/')
    $t = Get-TfsTeam -Team $teamId -Project $projId
    return $t.Name
})
</GetScriptBlock>
      </ScriptProperty>
      <ScriptProperty>
        <Name>Project</Name>
        <GetScriptBlock>return [TfsCmdlets.Util.LazyProperty]::Get($this, 'Project', {
    $u = [uri] $_.Links.Links.board.Href
    $projId = $u.Segments[-6].TrimEnd('/')
    $tp = Get-TfsTeamProject -Project $projId
    return $tp.Name
})
</GetScriptBlock>
      </ScriptProperty>
      <ScriptProperty>
        <Name>CardRules</Name>
        <GetScriptBlock>$this.rules['fill']</GetScriptBlock>
      </ScriptProperty>
      <ScriptProperty>
        <Name>TagRules</Name>
        <GetScriptBlock>$this.rules['tagStyle']</GetScriptBlock>
      </ScriptProperty>
    </Members>
  </Type>
  <Type>
    <Name>Microsoft.TeamFoundation.WorkItemTracking.Client.Link</Name>
    <Members>
      <ScriptProperty>
        <Name>LinkType</Name>
        <GetScriptBlock>function _GetBuildArtifactKind($type, $id)
    {
    return 'Build'
    }
 
    function _GetRequirementsArtifactKind($type, $id)
    {
    return 'Storyboard'
    }
 
    function _GetGitArtifactKind($type, $id)
    {
    if ($type -eq 'Ref')
    {
    $pathSegments = $id -split '%2F'
    if ($pathSegments[2].StartsWith('GB'))
    {
    $type = 'Branch'
    }
    elseif ($pathSegments[2].StartsWith('GT'))
    {
    $type = 'Tag'
    }
    }
 
    return $type
    }
 
    function _GetTestManagementArtifactKind($type, $id)
    {
    if ($type -like 'TcmResultAttachment*')
    {
    return 'Test Result Attachment'
    }
    if ($type -like 'TcmResult*')
    {
    return 'Test Result'
    }
    return $type
    }
 
    function _GetVersionControlArtifactKind($type, $id)
    {
    if ($type -ne 'Changeset')
    {
    return 'Versioned Item'
    }
    return 'Changeset'
    }
 
    function _GetExternalLinkTypeName($link)
    {
    if ($link.LinkedArtifactUri -like 'vstfs:///*')
    {
    $uri = [uri] $link.LinkedArtifactUri
    $artifactKind = $uri.Segments[1] -replace '/', ''
    $func = "_Get$($artifactKind)ArtifactKind"
    return &amp; $func ($uri.Segments[2] -replace '/', '') $uri.Segments[3]
    }
    return 'External'
    }
 
    try
    {
    switch($this.BaseType)
    {
    'RelatedLink' { $this.LinkTypeEnd.Name }
    'WorkItemLink' { $this.LinkTypeEnd.Name }
    'ExternalLink' { _GetExternalLinkTypeName $this }
    default { $this.BaseType }
    }
    }
    catch
    {
    $_.Exception.ToString()
    }</GetScriptBlock>
      </ScriptProperty>
      <ScriptProperty>
        <Name>LinkTarget</Name>
        <GetScriptBlock>function _GetOwner($link)
    {
    $field = $link.GetType().GetField('m_item', [System.Reflection.BindingFlags]::NonPublic -bor [System.Reflection.BindingFlags]::Instance)
    if ($field)
    {
    return $field.GetValue($link)
    }
    throw 'm_item private field not found in link $($link.GetType().FullName)'
    }
 
    function _GetTpc($link)
    {
    $wi = _GetOwner $link
    return $wi.Store.TeamProjectCollection
    }
 
    function _GetBuildArtifactTarget($type, $id)
    {
    return $id
    }
 
    function _GetRequirementsArtifactTarget($type, $id)
    {
    return [System.Net.WebUtility]::UrlDecode($id)
    }
 
    function _GetGitArtifactTarget($type, $id)
    {
    $pathSegments = $id -split '%2F'
 
    if ($pathSegments.Count -ne 3)
    {
    return $id
    }
 
    $id = $pathSegments[2]
 
    if ($pathSegments[2].StartsWith('GB') -or $pathSegments[2].StartsWith('GT'))
    {
    $id = $pathSegments[2].Substring(2)
    }
 
    return $id
    }
 
    function _GetTestManagementArtifactTarget($type, $id, $link)
    {
      return $link.LinkedArtifactUri
    }
 
    function _GetVersionControlArtifactTarget($type, $id, $link)
    {
    if ($type -eq 'VersionedItem')
    {
    (0..2) | Foreach-Object { $id = [System.Net.WebUtility]::UrlDecode($id) }
    $id = $id -split '&amp;'
        return "`$/$($id[0]) ($($id[1]), $($id[2]))"
      }
 
      if ($type -eq 'LatestItemVersion')
      {
        $tpc = _GetTpc $link
        $vcs = $tpc.GetService([type]"Microsoft.TeamFoundation.VersionControl.Client.VersionControlServer")
        $item = $vcs.GetItem([int]$id,$vcs.GetLatestChangesetId())
        return "$($item.ServerItem) (latest version)"
      }
       
      return $id
    }
 
    function _GetExternalLinkLocation($link)
    {
      if ($link.LinkedArtifactUri -like 'vstfs:///*')
      {
        $uri = [uri] $link.LinkedArtifactUri
        $artifactKind = $uri.Segments[1] -replace '/', ''
        $func = "_Get$($artifactKind)ArtifactTarget"
        return &amp; $func ($uri.Segments[2] -replace '/', '') $uri.Segments[3] $link
    }
 
    return $link.LinkedArtifactUri
    }
 
    try
    {
    switch($this.BaseType)
    {
    'HyperLink' { $this.Location }
    'RelatedLink' { "Work Item #$($this.RelatedWorkItemId)" }
    'ExternalLink' { _GetExternalLinkLocation $this }
    'WorkItemLink' { "Work Item #$($this.TargetId)" }
    default { '' }
    }
    }
    catch
    {
    $_.Exception.ToString()
    }</GetScriptBlock>
      </ScriptProperty>
    </Members>
  </Type>
  <Type>
    <Name>Microsoft.TeamFoundation.WorkItemTracking.Client.Project</Name>
    <Members>
      <ScriptProperty>
        <Name>ProcessTemplate</Name>
        <GetScriptBlock>try
    {
    $projectName = $null
    $projectState = $null
    $templateId = $null
    $projectProperties = $null
 
    $tpc = $this.Store.TeamProjectCollection
    $css = $tpc.GetService([type]'Microsoft.TeamFoundation.Server.ICommonStructureService')
    $css.GetProjectProperties($this.Uri, [ref] $projectName, [ref] $projectState, [ref] $templateId, [ref] $projectProperties)
 
    $processTemplate = $projectProperties | Where-Object Name -eq "Process Template" | select -ExpandProperty Value
 
    if([string]::IsNullOrEmpty($processTemplate))
    {
    $processTemplate = "(Unknown)"
    }
 
    return $processTemplate
    }
    catch
    {
    return "(Error)"
    }</GetScriptBlock>
      </ScriptProperty>
      <ScriptProperty>
        <Name>Collection</Name>
        <GetScriptBlock>$this.Store.TeamProjectCollection.DisplayName</GetScriptBlock>
      </ScriptProperty>
    </Members>
  </Type>
  <Type>
    <Name>Microsoft.TeamFoundation.WorkItemTracking.Client.QueryDefinition</Name>
    <Members>
      <ScriptProperty>
        <Name>ParentPath</Name>
        <GetScriptBlock>$this.Parent.Path</GetScriptBlock>
      </ScriptProperty>
    </Members>
  </Type>
  <Type>
    <Name>Microsoft.TeamFoundation.WorkItemTracking.Client.QueryDefinition2</Name>
    <Members>
      <ScriptProperty>
        <Name>ProjectName</Name>
        <GetScriptBlock>$this.Path.Substring(0, $this.Path.IndexOf('/'))</GetScriptBlock>
      </ScriptProperty>
      <ScriptProperty>
        <Name>ScopeName</Name>
        <GetScriptBlock>($this.Path -split '/')[1]</GetScriptBlock>
      </ScriptProperty>
      <ScriptProperty>
        <Name>ParentPath</Name>
        <GetScriptBlock>$this.Parent.Path</GetScriptBlock>
      </ScriptProperty>
      <ScriptProperty>
        <Name>RelativePath</Name>
        <GetScriptBlock>$this.Path.Substring($this.Path.IndexOf('/', $this.QueryHierarchy.Name.Length+2)+1)</GetScriptBlock>
      </ScriptProperty>
    </Members>
  </Type>
  <Type>
    <Name>Microsoft.TeamFoundation.WorkItemTracking.Client.QueryFolder</Name>
    <Members>
      <ScriptProperty>
        <Name>RelativePath</Name>
        <GetScriptBlock>$this.Path.Substring($this.Path.IndexOf('/')+1)</GetScriptBlock>
      </ScriptProperty>
      <ScriptProperty>
        <Name>ParentPath</Name>
        <GetScriptBlock>$this.Path.Substring(0, $this.Path.Length - $this.Name.Length - 1)</GetScriptBlock>
      </ScriptProperty>
      <ScriptProperty>
        <Name>ProjectName</Name>
        <GetScriptBlock>$this.Path.Substring(0, $this.Path.IndexOf('/'))</GetScriptBlock>
      </ScriptProperty>
    </Members>
  </Type>
  <Type>
    <Name>Microsoft.TeamFoundation.WorkItemTracking.Client.QueryFolder2</Name>
    <Members>
      <ScriptProperty>
        <Name>ParentPath</Name>
        <GetScriptBlock>$this.Path.Substring(0, $this.Path.Length - $this.Name.Length - 1)</GetScriptBlock>
      </ScriptProperty>
      <ScriptProperty>
        <Name>RelativePath</Name>
        <GetScriptBlock>$this.Path.Substring($this.Path.IndexOf('/')+1)</GetScriptBlock>
      </ScriptProperty>
      <ScriptProperty>
        <Name>ProjectName</Name>
        <GetScriptBlock>$this.Path.Substring(0, $this.Path.IndexOf('/'))</GetScriptBlock>
      </ScriptProperty>
    </Members>
  </Type>
  <Type>
    <Name>Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItem</Name>
    <Members>
      <ScriptProperty>
        <Name>AssignedTo</Name>
        <GetScriptBlock>try
    {
    return $this.Fields["System.AssignedTo"].Value
    }
    catch
    {
    return "(Error)"
    }</GetScriptBlock>
        <SetScriptBlock>$this.Fields["System.AssignedTo"].Value = $args[0]</SetScriptBlock>
      </ScriptProperty>
      <ScriptProperty>
        <Name>WorkItemType</Name>
        <GetScriptBlock>$this.Type.Name</GetScriptBlock>
      </ScriptProperty>
      <ScriptProperty>
        <Name>Collection</Name>
        <GetScriptBlock>$this.Store.TeamProjectCollection.DisplayName</GetScriptBlock>
      </ScriptProperty>
    </Members>
  </Type>
  <Type>
    <Name>Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItemLinkTypeEnd</Name>
    <Members>
      <ScriptProperty>
        <Name>OppositeEndName</Name>
        <GetScriptBlock>return $this.OppositeEnd.Name</GetScriptBlock>
      </ScriptProperty>
    </Members>
  </Type>
  <Type>
    <Name>Microsoft.TeamFoundation.WorkItemTracking.WebApi.Models.QueryHierarchyItem</Name>
    <Members>
      <ScriptProperty>
        <Name>ItemType</Name>
        <GetScriptBlock>if($this.IsFolder){return 'Folder'}else{return 'Query'}</GetScriptBlock>
      </ScriptProperty>
      <ScriptProperty>
        <Name>Folder</Name>
        <GetScriptBlock>return "/$($this.Path.TrimEnd($this.Name).TrimEnd('/'))"</GetScriptBlock>
      </ScriptProperty>
      <ScriptProperty>
        <Name>Project</Name>
        <GetScriptBlock>return [TfsCmdlets.Util.LazyProperty]::Get($this, 'TeamProject', {
    $url = [uri] $_.Url.SubString(0, $_.Url.IndexOf('/_apis/'))
    $tp = Get-TfsTeamProject $url.Segments[2]
    return $tp.Name
})
</GetScriptBlock>
      </ScriptProperty>
    </Members>
  </Type>
  <Type>
    <Name>Microsoft.TeamFoundation.WorkItemTracking.WebApi.Models.WorkItem</Name>
    <Members>
      <ScriptProperty>
        <Name>Id</Name>
        <GetScriptBlock>$uri = ([uri]$this.Url); if($uri.Segments[-2] -eq 'revisions/'){[int]$uri.Segments[-3].TrimEnd('/')}else{[int]$uri.Segments[-1].TrimEnd('/')}</GetScriptBlock>
      </ScriptProperty>
      <ScriptProperty>
        <Name>Title</Name>
        <GetScriptBlock>$this.Fields['System.Title']</GetScriptBlock>
      </ScriptProperty>
      <ScriptProperty>
        <Name>Revision</Name>
        <GetScriptBlock>$this.Rev</GetScriptBlock>
      </ScriptProperty>
      <ScriptProperty>
        <Name>WorkItemType</Name>
        <GetScriptBlock>$this.Fields['System.WorkItemType']</GetScriptBlock>
      </ScriptProperty>
      <ScriptProperty>
        <Name>State</Name>
        <GetScriptBlock>$this.Fields['System.State']</GetScriptBlock>
      </ScriptProperty>
      <ScriptProperty>
        <Name>Reason</Name>
        <GetScriptBlock>$this.Fields['System.Reason']</GetScriptBlock>
      </ScriptProperty>
      <ScriptProperty>
        <Name>AssignedTo</Name>
        <GetScriptBlock>$this.Fields['System.AssignedTo'].DisplayName</GetScriptBlock>
      </ScriptProperty>
      <ScriptProperty>
        <Name>AreaPath</Name>
        <GetScriptBlock>$this.Fields['System.AreaPath']</GetScriptBlock>
      </ScriptProperty>
      <ScriptProperty>
        <Name>IterationPath</Name>
        <GetScriptBlock>$this.Fields['System.IterationPath']</GetScriptBlock>
      </ScriptProperty>
      <ScriptProperty>
        <Name>Tags</Name>
        <GetScriptBlock>$this.Fields['System.Tags']</GetScriptBlock>
      </ScriptProperty>
      <ScriptProperty>
        <Name>Description</Name>
        <GetScriptBlock>$this.Fields['System.Description']</GetScriptBlock>
      </ScriptProperty>
      <ScriptProperty>
        <Name>ChangedDate</Name>
        <GetScriptBlock>$this.Fields['System.ChangedDate']</GetScriptBlock>
      </ScriptProperty>
      <ScriptProperty>
        <Name>TeamProject</Name>
        <GetScriptBlock>($this.Fields['System.AreaPath'] -split '\\')[0]</GetScriptBlock>
      </ScriptProperty>
    </Members>
  </Type>
  <Type>
    <Name>Microsoft.TeamFoundation.WorkItemTracking.WebApi.Models.WorkItemClassificationNode</Name>
    <Members>
      <ScriptProperty>
        <Name>NodeType</Name>
        <GetScriptBlock>return $this.StructureType</GetScriptBlock>
      </ScriptProperty>
      <ScriptProperty>
        <Name>TeamProject</Name>
        <GetScriptBlock>$this.Path.Substring(1, $this.Path.IndexOf('\', 2)-1)</GetScriptBlock>
      </ScriptProperty>
      <ScriptProperty>
        <Name>FullPath</Name>
        <GetScriptBlock>$this.Path.Replace("\$($this.TeamProject)\$($this.StructureType)", "\$($this.TeamProject)")</GetScriptBlock>
      </ScriptProperty>
      <ScriptProperty>
        <Name>RelativePath</Name>
        <GetScriptBlock>$this.Path.Substring($this.Path.IndexOf('\', $this.Path.Substring(0, $this.Path.IndexOf('\',1)+1).Length) + 1)</GetScriptBlock>
      </ScriptProperty>
      <ScriptProperty>
        <Name>StartDate</Name>
        <GetScriptBlock>$this.Attributes['startDate']</GetScriptBlock>
      </ScriptProperty>
      <ScriptProperty>
        <Name>FinishDate</Name>
        <GetScriptBlock>$this.Attributes['finishDate']</GetScriptBlock>
      </ScriptProperty>
      <ScriptProperty>
        <Name>Uri</Name>
        <GetScriptBlock>([uri] "vstfs:///Classification/Node/$($this.Identifier)")</GetScriptBlock>
      </ScriptProperty>
    </Members>
  </Type>
  <Type>
    <Name>Microsoft.TeamFoundation.WorkItemTracking.WebApi.Models.WorkItemRelation</Name>
    <Members>
      <ScriptProperty>
        <Name>LinkType</Name>
        <GetScriptBlock>if($this.Rel -eq 'AttachedFile') { 'Attachment' } elseif($this.Attributes['name']) {$this.Attributes['name']} else {$this.Rel}</GetScriptBlock>
      </ScriptProperty>
      <ScriptProperty>
        <Name>Comment</Name>
        <GetScriptBlock>$this.Attributes['comment']</GetScriptBlock>
      </ScriptProperty>
      <ScriptProperty>
        <Name>Target</Name>
        <GetScriptBlock>if($this.Rel -eq 'AttachedFile')
{
  return $this.Attributes['name']
}
elseif (-not $this.Attributes['name'])
{
    return $this.Url
}
elseif ($this.Url -like 'vstfs:/*')
{
    $segments = $this.Url.Substring(9).Split('/')
    if($segments.Length -eq 3) { $segments[2] = [uri]::UnescapeDataString($segments[2]) }
    return $segments -join ' '
}
 
$id = [int] ([uri] $this.Url).Segments[-1]
$wi = Get-TfsWorkItem -WorkItem $id
 
return "$($wi.WorkItemType) #$($id) (""$($wi.Title)"")"
</GetScriptBlock>
      </ScriptProperty>
    </Members>
  </Type>
  <Type>
    <Name>Microsoft.TeamFoundation.WorkItemTracking.WebApi.Models.WorkItemType</Name>
    <Members>
      <ScriptProperty>
        <Name>Project</Name>
        <GetScriptBlock>return [TfsCmdlets.Util.LazyProperty]::Get($this, 'Project', {
    $url = [uri] $_.Url.SubString(0, $_.Url.IndexOf('/_apis/'))
    $tp = Get-TfsTeamProject $url.Segments[2]
    return $tp.Name
})
</GetScriptBlock>
      </ScriptProperty>
    </Members>
  </Type>
  <Type>
    <Name>Microsoft.VisualStudio.Services.Feed.WebApi.FeedView</Name>
    <Members>
      <ScriptProperty>
        <Name>Project</Name>
        <GetScriptBlock>return [TfsCmdlets.Util.LazyProperty]::Get($this, 'Project', {
    $url = [uri] $_.Url.SubString(0, $_.Url.IndexOf('/Views/'))
    $id = $url.Segments[-5].Trim('/')
    return Get-TfsTeamProject -Project $id
})
</GetScriptBlock>
      </ScriptProperty>
      <ScriptProperty>
        <Name>Feed</Name>
        <GetScriptBlock>return [TfsCmdlets.Util.LazyProperty]::Get($this, 'Feed', {
    $url = [uri] $_.Url.SubString(0, $_.Url.IndexOf('/Views/'))
    $id = $url.Segments[-1].Trim('/')
    return Get-TfsArtifactFeed -Feed $id -Project $_.Project
})
</GetScriptBlock>
      </ScriptProperty>
    </Members>
  </Type>
  <Type>
    <Name>Microsoft.VisualStudio.Services.Feed.WebApi.Package</Name>
    <Members>
      <ScriptProperty>
        <Name>Feed</Name>
        <GetScriptBlock>return [TfsCmdlets.Util.LazyProperty]::Get($this, 'Feed', {
    $url = [uri] $_.Links.Links.feed.href
    $id = $url.Segments[-1].Trim('/')
    return Get-TfsArtifactFeed -Feed $id
})
</GetScriptBlock>
      </ScriptProperty>
      <ScriptProperty>
        <Name>Description</Name>
        <GetScriptBlock>$this.Versions[0].PackageDescription</GetScriptBlock>
      </ScriptProperty>
      <ScriptProperty>
        <Name>LatestVersion</Name>
        <GetScriptBlock>$this.Versions[0].Version</GetScriptBlock>
      </ScriptProperty>
      <ScriptProperty>
        <Name>IsListed</Name>
        <GetScriptBlock>$this.Versions[0].IsListed</GetScriptBlock>
      </ScriptProperty>
      <ScriptProperty>
        <Name>IsDeleted</Name>
        <GetScriptBlock>$this.Versions[0].IsDeleted</GetScriptBlock>
      </ScriptProperty>
      <ScriptProperty>
        <Name>Views</Name>
        <GetScriptBlock>$this.Versions[0].Views</GetScriptBlock>
      </ScriptProperty>
      <ScriptProperty>
        <Name>PublishDate</Name>
        <GetScriptBlock>$this.Versions[0].PublishDate</GetScriptBlock>
      </ScriptProperty>
    </Members>
  </Type>
  <Type>
    <Name>Microsoft.VisualStudio.Services.Feed.WebApi.PackageVersion</Name>
    <Members>
      <ScriptProperty>
        <Name>Package</Name>
        <GetScriptBlock>return [TfsCmdlets.Util.LazyProperty]::Get($this, 'Package', {
    $url = [uri] $_.Links.Links.package.href
    $id = $url.Segments[-1].Trim('/')
    $feedId = $url.Segments[-3].Trim('/')
    return Get-TfsArtifact -Package $id -Feed $feedId
})
</GetScriptBlock>
      </ScriptProperty>
      <ScriptProperty>
        <Name>Feed</Name>
        <GetScriptBlock>$this.Package.Feed</GetScriptBlock>
      </ScriptProperty>
      <ScriptProperty>
        <Name>Project</Name>
        <GetScriptBlock>$this.Feed.Project</GetScriptBlock>
      </ScriptProperty>
      <ScriptProperty>
        <Name>ProjectName</Name>
        <GetScriptBlock>$this.Project.Name</GetScriptBlock>
      </ScriptProperty>
      <ScriptProperty>
        <Name>FeedName</Name>
        <GetScriptBlock>$this.Feed.Name</GetScriptBlock>
      </ScriptProperty>
      <ScriptProperty>
        <Name>PackageName</Name>
        <GetScriptBlock>$this.Package.Name</GetScriptBlock>
      </ScriptProperty>
    </Members>
  </Type>
  <Type>
    <Name>Microsoft.VisualStudio.Services.Identity.Identity</Name>
    <Members>
      <ScriptProperty>
        <Name>IdentityType</Name>
        <GetScriptBlock>return &amp;{ if ($this.IsContainer) {'Group'} else {'User'} }</GetScriptBlock>
      </ScriptProperty>
      <ScriptProperty>
        <Name>AccountName</Name>
        <GetScriptBlock>return $this.Properties['Account']</GetScriptBlock>
      </ScriptProperty>
    </Members>
  </Type>
  <Type>
    <Name>Microsoft.VisualStudio.Services.Licensing.AccountEntitlement</Name>
    <Members>
      <ScriptProperty>
        <Name>DisplayName</Name>
        <GetScriptBlock>$this.User.DisplayName</GetScriptBlock>
      </ScriptProperty>
      <ScriptProperty>
        <Name>UniqueName</Name>
        <GetScriptBlock>$this.User.UniqueName</GetScriptBlock>
      </ScriptProperty>
      <ScriptProperty>
        <Name>Inactive</Name>
        <GetScriptBlock>$this.User.Inactive</GetScriptBlock>
      </ScriptProperty>
    </Members>
  </Type>
  <Type>
    <Name>Microsoft.VisualStudio.Services.ReleaseManagement.WebApi.Folder</Name>
    <Members>
      <ScriptProperty>
        <Name>Name</Name>
        <GetScriptBlock>if($this.Path -eq '\') { '\' } else { $this.Path.Substring($this.Path.LastIndexOf('\')+1) }</GetScriptBlock>
      </ScriptProperty>
    </Members>
  </Type>
  <Type>
    <Name>Microsoft.VisualStudio.Services.Search.WebApi.Contracts.WorkItem.WorkItemResult</Name>
    <Members>
      <ScriptProperty>
        <Name>TeamProject</Name>
        <GetScriptBlock>$this.Project.Name</GetScriptBlock>
      </ScriptProperty>
      <ScriptProperty>
        <Name>Id</Name>
        <GetScriptBlock>$this.Fields['system.id']</GetScriptBlock>
      </ScriptProperty>
      <ScriptProperty>
        <Name>Revision</Name>
        <GetScriptBlock>$this.Fields['system.rev']</GetScriptBlock>
      </ScriptProperty>
      <ScriptProperty>
        <Name>WorkItemType</Name>
        <GetScriptBlock>$this.Fields['system.workitemtype']</GetScriptBlock>
      </ScriptProperty>
      <ScriptProperty>
        <Name>State</Name>
        <GetScriptBlock>$this.Fields['system.state']</GetScriptBlock>
      </ScriptProperty>
      <ScriptProperty>
        <Name>ChangedDate</Name>
        <GetScriptBlock>$this.Fields['system.changeddate']</GetScriptBlock>
      </ScriptProperty>
      <ScriptProperty>
        <Name>AssignedTo</Name>
        <GetScriptBlock>$this.Fields['system.assignedto']</GetScriptBlock>
      </ScriptProperty>
      <ScriptProperty>
        <Name>Title</Name>
        <GetScriptBlock>$this.Fields['system.title']</GetScriptBlock>
      </ScriptProperty>
    </Members>
  </Type>
  <Type>
    <Name>Microsoft.VisualStudio.Services.TestManagement.TestPlanning.WebApi.TestPlan</Name>
    <Members>
      <ScriptProperty>
        <Name>TeamProject</Name>
        <GetScriptBlock>$this.Project.Name</GetScriptBlock>
      </ScriptProperty>
    </Members>
  </Type>
  <Type>
    <Name>Microsoft.VisualStudio.Services.WebApi.VssConnection</Name>
    <Members>
      <ScriptProperty>
        <Name>Name</Name>
        <GetScriptBlock>if($this.ParentConnection) { return $this.CollectionInfo.Name } else { return $this.Uri.Host }</GetScriptBlock>
      </ScriptProperty>
      <ScriptProperty>
        <Name>CollectionInfo</Name>
        <GetScriptBlock>return [TfsCmdlets.Util.LazyProperty]::Get($this, 'CollectionInfo', {
    Invoke-TfsRestApi "_apis/projectCollections/$($_.ServerId)" -Collection $_
})
</GetScriptBlock>
      </ScriptProperty>
    </Members>
  </Type>
</Types>