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:

https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_pipelines?view=powershell-6
https://mcpmag.com/articles/2015/06/11/powershell-functions-for-the-pipeline.aspx
https://blogs.technet.microsoft.com/heyscriptingguy/2013/03/25/learn-about-using-powershell-value-binding-by-property-name