ValueFromPipeline usage

I have two cmdlets, Get-MyBuilding and Get-MyRoom, which pull information on buildings and rooms from a school API. Each room belongs to a building, and therefore has a BuildingID. Get-MyRoom can be used with either “-RoomID” or “-BuildingID”.

In the same way as you would use [pre]Get-ADGroup “mygroup” | Get-ADGroupMember[/pre] I would like to be able to call [pre]Get-MyBuilding “mybuilding” | Get-MyRoom[/pre]

My question is, can this pipeline usage be achieved with ValueFromPipeline, or will it only work with ValueFromPipelineByPropertyName? To make things more complicated, I also want the -RoomID parameter to support pipeline input.

Any advice appreciated!

Sure, just write you own function with parameters that define value from pipeline.
Yet, know that much of the built-in cmdlets already support value from the pipeline, as long as there is matching parameter or value.
So, you can look at their source code to see how that was done, or see if you can achieve insight using the following: