I have this code below and I would like to display the output in a table like fashion
$spSite = Get-SPSite "http://sp2010"
$spWeb = $spSite.OpenWeb()
$spList = $spWeb.Lists["ReportList"]
$items = $spList.Items
foreach($item in $items)
{
Write-Host $item["ID"] $item["Name"] $item["Department"] $item["Telephone"]
}
like this:
ID Name Department Telephone
--- -------- ----------- ------------
1 Somone IT 02554445588
I saw Format-Table, but I cannot seem to get the hang of it.
Some example using the code above will be very much appreciated.
Thanks a lot.
Hard to even start helping, because current code simply won’t work… ($spListItem is… what? foreach uses $item, can we assume you are using it?). Also: we have very little to no information about type of this items, it looks like some dictionary object… Anyway, I would try:
obviously, it may not work, because I made some assumptions that can be just wrong.. 😉