example of using PowerShell to interactively dig into an object model

I was trying to modify a work item today and put in, apparently, too much text into a field

I really hate that experience – it doesn’t tell me the 2 pieces of information I want to know – what’s the max length for the field, and what’s the length for the string (value) I put in?  Ugh.  I don’t want to go on some bisection search to figure out how much data I can actually shove into the field.  Maybe I can get Naren to change that 🙂

Well, Jason (formerly on the WIT team) kindly dropped by to help me navigate the WIT object model to figure out the type of the field (and therefore the max length for it).  Since he knew where to check in the OM, I just made a call to get-tfs and we did some inspection.  Here’s the history entries from our inspection.  I won’t bore you with the output of each, but it should be obvious that we were able to dig into each layer by the output of the previous command.  It’s really fun and informative to dig into an object model like this 🙂  Intellisense is nice, but it’s so much nicer when it’s backed with data that you can get back interactively!

Oh, and the field was a String type (FieldType == String), so the max is like 250 or something, Jason explained.


C:\Users\jmanning\Documents\bin\tfs# history 23 -count 11

Id CommandLine
— ———–
13 $tfs = get-tfs ‘http://tkbgitvstfat01:8080′
14 $tfs.wit
15 $tfs.wit.Projects[‘Orcas’]
16 $tfs.wit.Projects[‘Orcas’].WorkItemTypes[‘Orcas Bug’]
17 $tfs.wit.Projects[‘Orcas’].WorkItemTypes[‘Orcas Bug’].FieldDefinitions[‘Customer Feedback’]
18 $tfs.wit.Projects[‘Orcas’].WorkItemTypes[‘Orcas Bug’].FieldDefinitions
19 $tfs.wit.Projects[‘Orcas’].WorkItemTypes[‘Orcas Bug’].FieldDefinitions | select Name,SystemType
20 $tfs.wit.Projects[‘Orcas’].WorkItemTypes[‘Orcas Bug’].FieldDefinitions[‘Description’]
21 $tfs.wit.Projects[‘Orcas’].WorkItemTypes[‘Orcas Bug’].FieldDefinitions[‘Customer Feedback’]
22 $tfs.wit.Projects[‘Orcas’].WorkItemTypes[‘Orcas Bug’].FieldDefinitions | select Name,FieldType
23 $tfs.wit.Projects[‘Orcas’].WorkItemTypes[‘Orcas Bug’].FieldDefinitions | select Name,FieldType|sort FieldType

Comments (0)

Skip to main content