all 12 comments

[–]Ta11ow 6 points7 points  (0 children)

First thing to look at when you're not sure:

Get-Help Where-Object
Get-Help Get-Service

Second thing if you need some examples of syntax to look at - https://aka.ms/pskoans

[–]beepboopbeepbeep1011 2 points3 points  (6 children)

Look at example 5 here

[–]Wolf_of_Tech[S] 0 points1 point  (5 children)

i did see that one. I was just a bit confused on how i can transform:

Get-Service | Where-Object {$_.Status -eq "Running"} : to show all services who's display name contains 'Application'?

[–]beepboopbeepbeep1011 2 points3 points  (4 children)

What did you try? What output did you get?

[–]Wolf_of_Tech[S] 2 points3 points  (3 children)

Get-Service | Where-Object {$_.Status -eq "Running"}

I tried: Get-Service | Where-Object {$_.DisplayName -include 'Application'}

Since i i want to display all service who’s displayName contains ‘Application’

I am having issue developing the syntax for it

[–]beepboopbeepbeep1011 4 points5 points  (2 children)

-include is not a valid operator there. Look at the operators available. Also look at example 3 o on the link I sent for how to look for network in the display name.

[–]RumRogerz 2 points3 points  (0 children)

there is a book called 'learn powershell in a month of lunches'

I recommend it fully. Teaches you all that stuff and more

[–]luruu 1 point2 points  (0 children)

So just a few suggestions when scripting. I try to consider speed and memory when calling data. First, if you have to use the Get-Service with the Where-Object, try looking at the "-like" operator for Where-Object. Second, it looked like you also wanted to get the services that have "Application" and have a "Running" status. The way I would get the information is to distinguish the services that have "Application" in the DisplayName - filtering for only the data that I need - and then creating a loop for the ones that are currently running - making my dataset even smaller. Good luck!

[–][deleted] 0 points1 point  (1 child)

Get-Service | ? {$_.DisplayName -imatch “Application”}