I have been investigating with controlling powershell with tfs.
Other people have tried such as here and here.
Here is an example of creating a work item in powershell
The Tfs power tools project includes some powershell scripts yet fails to install them by default!
You need to repair the installation and then install the powershell scripts.
Even then you only get the x86 versions so you need to remember to use the x86 ISE/powershell console.
The following is the result of some experimentation with a free visualstudio.com tfs account.
It is not easy to authenticate against this so you need to map to a workspace and use the workspace to identify the server.
#This needs to use the x86 version of the ise
#OK you need to map the server to a local folder that is a workspace
#This returns a real tfs object
$tfs = Get-TfsServer -Path “d:devTFSTesting”
#With some powershell type trickery you can get to the other useful services.
$wit = $tfs.GetService([Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItemStore])
#This shows that you can programatically get a specific work item (I only have this work item).
#This demonstrates changing it
$wi = $wit.GetWorkItem(1)
$wi.Title = “Adjusted”
$wit.Projects[“TFSTesting”].StoredQueries | select Name,QueryGuid,QueryText
#Your GUID will vary.
$q = $wit.GetStoredQuery(“a6316d4a-7139-468c-b200-c9754e9de5c4″).QueryText.ToString()
#Example simple query
Select [State], [Title]
Where [Work Item Type] = ‘Product Backlog Item’
Order By [State] Asc, [Changed Date] Desc”)
#Adding a simple work item
$workItem = new-object Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItem($wit.Projects[“TFSTesting”].WorkItemTypes[“Product Backlog Item”])
$workItem.Title = “Created by Windows PowerShell!”
#More work needs to be done to ensure that the work items have the correct properties .