Powershell: filter result on columns?


How can I achieve this (want to filter out status out of get-service but do not want to use get-service | select-object name,displayname

 get-service | Where-Object -NE status

Thanks for your input.
Who is Participating?
You can't remove properties from an object.
In other words: if you want to get rid of the Status property, you're going to have to use Select-Object.
What is it exactly that you want to achieve, and what's wrong with Select-Object?
Perhaps you mean you don't want to have to specify all the properties you do want with Select-Object?
get-service | select-object * -excludeProperty Status

Open in new window

janhoedtAuthor Commented:
Thanks for the input. I have an output which belongs on input.
Scan-Network -port x,y,z gives

HostName Portx Porty Portz ThenAnObjectIdonotWant01 ThenAnObjectIdonotWant02

So I want select-object  HostName, Portx,Porty,Portz but extra ports can be added and I won't know them beforehand.
What I DO know is that I don't want is ThenAnObjectIdonotWant01, ThenAnObjectIdonotWant02 so wanted to DE-select them.
Select-Object's accepts wildcards both for Property and ExcludeProperty (and even ExpandProperty, provided it matches only one property).
If you only want Hostname and anything starting with Port, you just do
Scan-Network -Port x, y, z | Select-Object -Property HostName, Port*

Open in new window

Or to exclude properties matching a pattern:
Scan-Network -Port x, y, z | Select-Object -Property * -ExcludeProperty DropThisProperty, ThenAnObjectIdonotWant*

Open in new window

All Courses

From novice to tech pro — start learning today.