There are some environmental issues in your environment.
Bits is the exact name of the service.
Using the ‘*’ is of course just a wildcard that says give me anything that starts with bits.
Either approach is fine, as it should return the named service / services which match the defined name / string pattern.
So, I would not stress out over it, generally, but again, this looks to be environmental as there is really nothing special about what you are doing or how you are doing it.
The pipeline is all about passing the results (or part of it) to another item.
There are several commands that have a computername property / switch and just work on remote systems without any more real effort.Of course there are many ways to do thing on PoSH. Example, all the below do the same thing
So, this is get all AD computer base properties, select name from the properties, and create a new property called computername to match the property Get-service.
Get-ADComputer -filter * | select -property @{n=“ComputerName”;e={$_.name}} | Get-Service -name BITS
Here’s the deal though with these two cmdlets. There is no property called ComputerName in either of them.
One has Name, and the other is called machine name. So, using computername as a match is moot.
The Pipeline will try and match by property name or by value.
See details here:
‘blogs.technet.microsoft.com/heyscriptingguy/2013/03/25/learn-about-using-powershell-value-binding-by-property-name’
‘mcpmag.com/articles/2015/05/20/functions-that-support-the-pipeline.aspx’
These both provide a matching value. So, that is what the pipeline will use.
(Get-ADComputer -Filter *)[0]
DistinguishedName : CN=DC01,OU=Domain Controllers,DC=contoso,DC=com
DNSHostName : DC01.contoso.com
Enabled : True
Name : DC01
ObjectClass : computer
ObjectGUID : fe693a48-96d1-4d62-a09a-2a009c707a4f
SamAccountName : DC01$
SID : S-1-5-21…
UserPrincipalName :
Get-Service -ComputerName $env-COMPUTERNAME -Name BITS | Select -Property *
Name : BITS
RequiredServices : {RpcSs, EventSystem}
CanPauseAndContinue : False
CanShutdown : False
CanStop : True
DisplayName : Background Intelligent Transfer Service
DependentServices : {}
MachineName : DC01
ServiceName : BITS
ServicesDependedOn : {RpcSs, EventSystem}
ServiceHandle : SafeServiceHandle
Status : Running
ServiceType : Win32ShareProcess
StartType : Manual
Site :
Container :
So, these two examples, return the same thing your example is designed to deliver
…as well as… No calculated properties needed. Just passing value match.
Get-ADComputer -filter * | % {Get-Service -ComputerName $_.Name -Name BITS}
Get-Service -ComputerName ((Get-ADComputer -filter *).Name) -Name BITS
If you are trying to match by property in this effort then…
get-adcomputer -filter * |select -property @{n=“ComputerName”;e={$_.name}} | Get-Service -name bits
…would be this…
get-adcomputer -filter * |select -property @{n=“MachineName”;e={$_.name}} | Get-Service -name bits
Thus converting the Name property from Get-ADCompputer to match the MachineName property in Get-Service.
Again, in this case it would not matter what you names the property, as the Pipeline will just grab matching values.