I’ve got a table made out of various fields of work items. This is the table layout:
$table = @{Expression = {$_.Fields['Id'].Value}; Label = "Id"},
@{Expression = {$_.Fields['Work Item Type'].Value}; Label = "Work Item Type"},
@{Expression = {$_.Fields['Title'].Value}; Label = "Title"},
@{Expression = {$_.Fields['State'].Value}; Label = "State"},
@{Expression = {$_.Fields['Substate'].Value}; Label = "Substate"},
@{Expression = {$_.Fields['Assigned To'].Value}; Label = "Assigned To"},
@{Expression = {$_.Fields['CreatedBy'].Value}; Label = "Developer"},
@{Expression = {$_.Fields['QA Responsible'].Value}; Label = "QA Responsible"},
@{Expression = {$_.Fields['Iteration Path'].Value}; Label = "Iteration Path"}
and from this line of code $workItems | Format-Table $table | Out-String i get a table like this:
Id Work Item Type Title State Substate Assigned To Developer QA Responsible Iteration Path
-- -------------- ----- ----- -------- ----------- --------- ----------- --------------
38479 Bug Title1000000...Resolved zzzzzzzzzzz... xxxxxxxxxxx... zzzzzzzzzzz... zzzzzzzzzzz QA\2012 August
34917 Task Title2000000...Resolved zzzzzzzzzzz... xxxxxxxxxxx WebXXX\CCCCCC
But when I try to convert it to HTML I get different values. Like these here:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>HTML TABLE</title>
</head><body>
<table>
<colgroup>
<col/>
</colgroup>
<tr><th>*</th></tr>
<tr><td>305</td></tr>
</table>
</body></html>
I just want to format the table in HTML and send it in an email. Can I get any help on this?
Okay, with Shay’s help I figured it out. I’ll post the answer here if anyone encounters similar problems. The fix was just at this line
$workItems | Format-Table $table | ConvertTo-Html. It needed to be changed to$workItems | Select-Object $table | ConvertTo-Html.Shay you helped me so much times, if you ever happen to be in Sarajevo, I’ll buy you a drink 🙂