Output format of TCM with PowerShell -


i try list of testsuites of specific testplan powershell , tcm.exe writing:

$listofsuites = & "c:\program files (x86)\microsoft visual studio 12.0\common7\ide\tcm.exe" suites /list /planid:1234 

i right result, formated single string like:

id        name                                                              --------- ----------------------------------------------------------------  1235      test project                                                 1236      test project -> manual tests -> first testsuite            1237      test project -> manual tests -> second testsuite 

is possible result list or table can iterated through these suites?

regards johannes

you single string if execute external program. in order receive string table, first call

$listofsuites.split("`r`n") 

to array of strings, need parse strings offset of strings in line-filled 1 (in case, 0 9 "id", 11 end "name"). example (taken this script):

$starters = new-object psobject -property @{"sessionname" = 0; "username" = 0;       "id" = 0; "state" = 0; "type" = 0; "device" = 0;};  foreach($line in $c) {      if($line.trim().substring(0, $line.trim().indexof(" ")) -eq "sessionname") {             $starters.username = $line.indexof("username");             $starters.id = $line.indexof("id");             $starters.state = $line.indexof("state");             $starters.type = $line.indexof("type");             $starters.device = $line.indexof("device");             continue;         }          new-object psobject -property @{             "sessionname" = $line.trim().substring(0, $line.trim().indexof(" ")).trim(">")             ;"username" = $line.substring($starters.username, $line.indexof(" ", $starters.username) - $starters.username)             ;"id" = $line.substring($line.indexof(" ", $starters.username), $starters.id - $line.indexof(" ", $starters.username) + 2).trim()             ;"state" = $line.substring($starters.state, $line.indexof(" ", $starters.state)-$starters.state).trim()             ;"type" = $line.substring($starters.type, $starters.device - $starters.type).trim()             ;"device" = $line.substring($starters.device).trim()     }  

$c result external command has no lines dashes , header formatted such:

 sessionname       username                 id  state   type        device 

once do, can turn each string new-object psobject -property @{"id"=$parsedid;"name"=$parsedname} , list of tailored objects work with. technique demonstrated in same example.


Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -