Now one for the SharePoint people.  You have ran SPDisposeCheck on the dire piece of code your lackey wrote (or youself for that matter) and forgot to run the SPDisposeCheck.  Whoosh loads of entries to validate and change the code for. 

Being good people using TFS for source code and task management you want an entry for each item to check.

Using the built in XML handling facilities from PowerShell this is an easy task.

First run SPDisposeCheck with the output set to XML You will get something like this

<?xml version=”1.0″ encoding=”ibm850″?>
<ArrayOfProblem xmlns:xsi=”” xmlns:xsd=””>
    <Assignment>local2 := new Microsoft.SharePoint.SPSite(local0).{Microsoft.SharePoint.SPSite}get_RootWeb()</Assignment>
    <Notes>Constructor called for Microsoft.SharePoint.SPSite but not assigned. This type should be assigned and subsequently disposed</Notes>


You can Easily read XML files in PowerShell with a simple statement

$xmldata = [xml](Get-Content c:testout.xml)

Accessing the Elements is then just object notation


Will return an array of problem items that can be accessed in a foreach $problem and with $problem.ID

So the full code to do this is


[psobject] $tfs = [Microsoft.TeamFoundation.Client.TeamFoundationServerFactory]::GetServer(“”)



$xmldata = [xml]

(Get-Content c:testout.xml) foreach ($problem in $xmldata.ArrayOfProblem.Problem){ $item = new-object Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItem $type $item.Title = “This is an automated entry based on the output from an SPDisposeCheck” $item.AreaPath = “MyProject” $item.IterationPath = “MyProjectIteration 2? $item.Description = “ID : ” + $problem.ID + ” Module : ” + $problem.Module + ” Method : ” + $problem.Method + ” Assignment : ” + $problem.Assignment + ” Line : ” + $problem.Line + ” Notes : ” + $problem.Notes + ” more :” + $problem.ID $ } 

You will want to test this on a TEST tfs project (something I recommend every team have else how are you going to figure out how it works)