I always thought that Powershell pipelining is achieved via either name or type matching ( as described in how pipelines work). That's ok for me. But how does Powershell achieves the following example:
> Get-Service "*win*" | ForEach-Object { Write-Host $_.DisplayName}
Get-Service
returns an object of type System.ServiceProcess.ServiceController
, ok. But Foreach-Object
only accepts PSObject
as InputObject
:
> Get-Help ForEach-Object -Parameter inputobject
-InputObject <PSObject>
...
Accept pipeline input? True (ByValue)
My question: How does Powershell convert any given object (because Foreach-Object
can accept any input object) to a PsObject
?
Thx