Clift Norris and I posted an article on CodeProject where we discuss a script to extract and build Visual Studio projects from TFS using PowerShell.
Automated Extract and Build from Team System using PowerShell
The accompanying PowerShell code may be useful as sample code if you want to program against TFS but don't want to solve the same problem we did.