Same Code but Different Display of Results

Hi, this is my first post for this forum as I am learning PowerShell.

Here is this code.

$XN = Get-Process -Name "Explorer" |Where-Object {$_.MainWindowTitle} |Select-Object -Property ID,Name,HasExited,MainWindowTitle
$TT = $XN.MainWindowTitle + "`n`n" + $XN

If there is only ONE instance of Windows Explorer, then it gives back in like a hash table format.


@{Id=1328; Name=explorer; HasExited=False; MainWindowTitle=C:\}

However, if there are two or more instances of Windows Explorer, then it returns in table format.


  Id Name     HasExited MainWindowTitle
  -- ----     --------- ---------------
1328 explorer     False C:\
9508 explorer     False D:\

Why the different display of the results?