I'm not actually the original author, but it seems pretty useful so I thought I'd pass it along - you'll need a reference to Microsoft.TeamFoundation.VersionControl.Client.dll, of course, which should be in your GAC if you have the Team Explorer bits