Getting all services and processes

Hi,

I’m at 9th chapter of Learn windows powershell in a month of lunches and have couple of questions. Could you please help on this?

1.Trying to get the list of services (without using any parantheses) from an OU. I’m getting error (cannot find any service with service name ‘@{computername=xyz}’) if i dont mention any specific service

Get-adcomputer -filter * -searchbase ‘ou=domain controllers,dc=abc-de,dc=abc,dc=com’ | select @{l=‘computer name’;e={$_.name}} | get-service

But i’m getting results if mention any service like below.

Get-adcomputer -filter * -searchbase ‘ou=domain controllers,dc=abc-de,dc=abc,dc=com’ | select @{l=‘computer name’;e={$_.name}} | get-service -name bits

May i know why the first command is not working and second is working?

2.Not sure why this below command is working perfectly whereas the first one (getting all services) is not working?

Get-adcomputer -filter * -searchbase ‘ou=domain controllers,dc=abc-de,dc=abc,dc=com’ | select @{l=‘computer name’;e={$_.name}} | get-process | export-csv Process.csv

 

 

Few other posts which will help you on this.

https://stackoverflow.com/questions/50319176/powershell-bug-cant-pipe-computername-property-to-get-service

https://powershell.org/forums/topic/piping-computers-to-get-service/

Thank you!