Skip to content

Instantly share code, notes, and snippets.

@cromwellryan
Last active December 11, 2015 20:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cromwellryan/4657224 to your computer and use it in GitHub Desktop.
Save cromwellryan/4657224 to your computer and use it in GitHub Desktop.
[Reflection.Assembly]::LoadWithPartialName("Microsoft.TeamFoundation.Client")
[Reflection.Assembly]::LoadWithPartialName("Microsoft.TeamFoundation.Common")
$script:tpcUrl "your tpc"
function Get-ShelvsetUrl {
<#
.Synopsis
Determines the url for a TFS Shelveset.
.Description
Determine the url for a TFS Shelveset and, optionally, copy or open the result.
.Parameter Name
The name of the Shelvset.
.Parameter Owner
The username of the Shelveset Owner.
.Parameter Launch
When true, the shelveset url will be opened in the default browser. Default: False.
.Parameter Copy
When true, the shelveset url will be placed in clipboard. Default: True.
.Example
get-shelveseturl -Shelveset "RDS - Profiling" -Owner "dev\\rcromwell"
Gets the shelvset url and places it in the clipboard.
.Example
get-shelveset "RDS - Profiling" "dev\\rcromwell" -Launch -Copy $false
Gets the shelvset url and places it in the clipboard. Uses position relative parameters for -Name and -Owner
Publishing a public Gist
#>
Param(
[Parameter(Position=0)]
$Name = (read-host "Shelveset"),
[Parameter(Position=1)]
$Owner = (read-host "Owner"),
[switch]$Launch = $false,
[switch]$Copy = $true
)
PROCESS {
$tpc = New-Object Microsoft.TeamFoundation.Client.TfsTeamProjectCollection $tpcUrl
$hlsvc = $tpc.GetService([Microsoft.TeamFoundation.Client.TswaClientHyperlinkService])
$details = $hlsvc.GetShelvesetDetailsUrl($Name, $Owner)
$url = $details.AbsoluteUri
if($Launch) { start $url }
if($Copy) { $url | clip }
$url
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment