Wednesday, January 26, 2011 #

Creating Team Foundation Work Items With PowerShell

Here is the simple function I added to my powershell profile:

 

 
 
 
 
 

 

function create-tfstask ($desc) {
 tfpt workitem /new $workItemType /collection:$serverUrl /fields:"Title=$($desc);Assigned To=$assignee;AreaId=$areaId;IterationId=$iterationId"
}

 

 
 
 

To find the AreaId and IterationId for your project/versions, just look at a bug you know is setup correctly:

PS C:\> tfpt query /collection:http://3bs001vsteam:8080/tfs /wiql:"select AreaId,IterationId from workitems where ID = 879"

Next I hooked this into my existing "todo" function by adding a new case in its $target switch statement for “tfs”, which calls my create-tfstask function and returns.  Updated todo function:

 
 
 
 
 
function todo {
  param([string] $target = "work",
        [string] $msg )
			
  $emailFrom = "lance@3birdsmarketing.com"
	
  #combine all the cmd line args into one "message"
  if ($args -ne "") {
    $msg = $msg + " " + $args
  }
	
  #what is the target of the message?
  switch ($target)
  {
    "work" { $target = "lance@3birdsmarketing.com" }
    "home" { $target = "lmrobins@gmail.com" }
    "tfs" { create-tfstask $msg; return }
  }	
	
  $subject = "Todo: " + $msg
  $body = $msg
  $smtpServer = "3bs001exch"	
  $smtp = new-object Net.Mail.SmtpClient($smtpServer, 25)
  $smtp.Send($emailFrom, $target, $subject, $body)
}
 
 
 
Technorati Tags: ,,

Posted On Wednesday, January 26, 2011 10:58 AM | Feedback (1)

Copyright © Lance Robinson

Design by Bartosz Brzezinski

Design by Phil Haack Based On A Design By Bartosz Brzezinski