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]