Link to home
Start Free TrialLog in
Avatar of janhoedt
janhoedt

asked on

Powershell: filter result on columns?

Hi,

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.
J.
Avatar of oBdA
oBdA

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

Avatar of janhoedt

ASKER

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.
ASKER CERTIFIED SOLUTION
Avatar of oBdA
oBdA

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial