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.
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.
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
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.
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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?