Last active
December 11, 2015 20:39
-
-
Save cromwellryan/4657224 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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