Question about Services Output

Hi,

Good day! I’m new to Powershell and trying a few things.

Can anyone help me show Stopped Services and the output would be like:

(WinRM is Stopped) - something like this.

I use the below syntax but I need to show the name of the service and some sort of output beside it hence I put in the write-host “is Stopped” thinking that it will show the name of the service and the output “is Stopped” beside.

Get-Service * | Where-Object {$_.Status -eq “Stopped”}
Write-host “is Stopped”

Any help would be appreciated :slight_smile:

Hmmm … in my opinion that does not look good … but you asked …

Get-Service | Where-Object -Property Status -EQ -Value Stopped | Select-Object -Property Name,@{Name=‘is’;Expression={‘is’}},Status
Get-Service | Where-Object -Property Status -EQ -Value Stopped | Select-Object -Property @{Name=‘Stopped Services’;Expression={"(.Name) is (.Status)"}}

Thanks Olaf looks very good and shows the name and status… So basically we created a some sort of Property name to show the word “Is” right?

I was told that it should show the name of the service (running or stopped) and just some sort of output beside it. It look simple when my pal gave me the assignment to practice but looks like it is not that simple after all. Lol

Sorry Olaf I just starting out and its just been 2 days :frowning: Just finished the CVT’s, reading books so need more practice.

No need to sorry … that’s what we’re all here for. To learn and to help. :smiley:

Yes, it’s called calculated properties. It’s one way to change the output to your requirements.

Usually there are several ways to accomplish a task. Another way could be this:

Get-Service | Where-Object -Property Status -EQ -Value Stopped | ForEach-Object -Process {"$($_.Name) is $($_.Status)"}

If you need more ‘input’ you will find some here: Beginner Sites And Tutorials :smiley:

There’s always more than one day to do it:

Get-Service | Where-Object -Property Status -Eq Stopped | ForEach-Object { Write-Host "$($PSItem.Name) is Stopped" }

Thanks a bunch Olaf and Stuart much much appreciated :slight_smile:

Have a nice weekend guys!