Pipeline ForEach Multiple ScriptBlock Formatting

Just trying to grasp this concept, now I know what it’s called
may be caveats / methods involved like

select -expand
(wrap it all up)
explicit out-host
or even pipe to | Tee-Object

Great online example helped me get to where I’m at, re example:
getting TlDr* of scheduled tasks

Challenge is ‘merging’ the output from TaskInfo

Get-ScheduledTask -TaskPath *MyTaskPath* | Get-ScheduledTaskInfo | 
select TaskName, TaskPath, LastRunTime, LastRunResult | fl

with info from Task to get user

Get-ScheduledTask -TaskPath *MyTaskPath* | select -ExpandProperty Principal | select -ExpandProperty UserId

with the example #10 I’ve got it kinda working, but the first output arrives a few empty lines above the others… anyway known pipeline foreach / other syntactical sugar available to get

a formatted list of selected properties from multiple objects in pipeline inputs?

eg how to improve this

Get-ScheduledTask -TaskPath *MyTaskPath* |
% -Begin $null -Process {$_.Principal | select -ExpandProperty UserId} ,
 {Get-ScheduledTaskInfo $_ | select TaskName, TaskPath, LastRunTime, LastRunResult} -End $null | fl

foreach multiplescriptblocks

Thanks in advance almight PS .{com | org :} :pray:

I cannot test at the moment but something like this should work actually:

Get-ScheduledTask -TaskPath *MyTaskPath* | 
ForEach-Object {
    $Info = Get-ScheduledTaskInfo -InputObject $_
    [PSCustomObject]@{
        TaskName      = $Info.TaskName
        TaskPath      = $Info.TaskPath
        LastRuntime   = $Info.LastRuntime
        LastRunResult = $Info.LastRunResult
        UserID        = $_.Principal.UserID
    }
}

You may read more about PSCustomObject here:

Brilliant, thanks Olaf :+1: worked first time. :pray: