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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.