Search code examples
powershelltfschangeset

Get current changeset in my local path using powershell


My Machine houses many changesets of source control. I am trying to find what changeset a specific folder belong to in TFS.

I can use powershell to retrieve all changesets. Using the developer command prompot for VS2012, I can run this command to retrieve the current changeset on my machine. I want to combine the two so I can get that from the powershell script. I'd rather to find the equivalent of that developer command in powershell.

Any ideas?


Solution

  • Here is the code I came up with:

    Set-Location -Path codepath 
    $exepath = "D:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\TF.exe"
    $result = & $exepath history . /r /noprompt /stopafter:1 /version:W
    "$result" -match "\d+"
    

    the changeset number is here: $matches[0]