Powershell pipelining: Convert System.ServiceProcess.ServiceController to PSObject

时间:2018-06-04 16:38:27

标签: powershell

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

0 个答案:

没有答案