Sort-Object a List

This code basically grabs all the properties of a Window Explorer instance and put it into a list.

Clear-Host
Get-Process -ID 10080 |
	Where-Object {$_.MainWindowTitle -NE "" -AND $_.MainWindowHandle -NE 0} |
	Format-List -Property *

Question #1: How do I properly SORT this? I keep getting an error with Sort-Object

Question #2: How can I exclude or return only the fields with data, without having to specified the exact fields?

Thanks

  1. Format-list, please never used it. this is why sort-object is not working for you.
  2. Select-object -property = will solved you problem.