Help with Powershell piping/ query

Running PS v2.0 for a particular application

If I run

get-server -status | fl

One of the values is

PatchingDay: Sunday

Our servers are named based on their region, so we have names like EMEA-Server1, EMEA-Server2, LATAM-Server1, etc

I would like a list of:

1. ALL servers with the PatchingDay value set to Sunday
2. Only EMEA servers with the PatchingDay value set to Sunday

Does anyone know the Powershell command I need to run this?
Who is Participating?
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.

Try the following two commands

get-server -status | where {$_.PatchingDay - eq "Sunday"} 

get-server -status | where {$_.PatchingDay - eq "Sunday" -and $ -like "EMEA*"}

Open in new window

Typo errors
get-server -status | where {$_.PatchingDay -eq "Sunday"} 

get-server -status | where {$_.PatchingDay -eq "Sunday" -and $ -like "EMEA*"}

Open in new window

Kamalasekar ParthasarathyMessaging SupportCommented:

you can try also,
Get-MailboxServer -Status | FL

It will show you the full list.. then you can select the appropriate title and find it.

Like Get-MailboxServer -Status | FL Name

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

kam_ukAuthor Commented:
Thanks prashanthd....could you explain how your commands work?
I am not sure if there is a cmdlet called get-server, but based on info given by you

get-server -status | where {$_.PatchingDay -eq "Sunday"}

Basically searches all servers | returns the ones for which PatchingDay equals "Sunday"

get-server -status | where {$_.PatchingDay -eq "Sunday" -and $ -like "EMEA*"}

same as above with additional condition where name starts "EMEA*", * is a wild character.

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
QlemoBatchelor, Developer and EE Topic AdvisorCommented:
In addition to above explanation:
In commands working on the pipe one by one, like foreach-object, select-object, where-object (where or ? is the abbreviation of where-object), the current processed object is $_, and you can access its properties directly.

However, you should always try to find a filter or restriction switch for your commandlet first, because that is much faster. Only if the commandlet does not support your restriction, you should apply "external" filters like where-object.
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.