Problem
I need to script my work item query administation.
Solution
Use the Work Item Query Administration tool from CodePlex http://wiqadmin.codeplex.com/
Examples
This will list out all the queries and the paths you need to export them
wiqadmin list /collection:http://MytfsUrl:8080/tfs/defaultcollection /p:MyProject /recursive
This is how you can export one once you know the path. Make sure you use “ on the path
wiqadmin export /collection:http://MytfsUrl:8080/tfs/defaultcollection /p:MyProject /n:"Team Queries/Iteration 1/Active Bugs" /f:bugs.wiql