Two function join results to 1 table

Welcome Forums General PowerShell Q&A Two function join results to 1 table

This topic contains 2 replies, has 2 voices, and was last updated by

 
Participant
2 years, 10 months ago.

  • Author
    Posts
  • #34056

    Participant
    Points: 0
    Rank: Member

    I have to function that return results in the same format. How do I join them to 1 table

    $bsparta = bing-sparta -content $path | ConvertTo-Html -Fragment 
    $bhaledon = bing-haledon -content $path  | ConvertTo-Html -Fragment
    
    PS C:\> $bsparta 
    
    Location                                     Distance In Miles                            Traffic Status                               Eta with Traffic                            
    --------                                     -----------------                            --------------                               ----------------                            
    Sparta                                       1 Miles                                      None                                         1 Minutes                                   
    
    
    
    PS C:\> $bhaledon 
    
    Location                                     Distance In Miles                            Traffic Status                               Eta with Traffic                            
    --------                                     -----------------                            --------------                               ----------------                            
    Haledon                                      52 Miles                                     Mild                                         68 Minutes                                  
    
    
  • #34057

    Member
    Points: 0
    Rank: Member

    Since these objects all have the same set of properties, you just need to use a single pipe to ConvertTo-Html. For example:

    $bsparta = bing-sparta -content $path
    $bhaledon = bing-haledon -content $path
    
    $table = $bsparta,$bhaledon | ConvertTo-Html -Fragment
    
  • #34058

    Participant
    Points: 0
    Rank: Member

    Awesome thanks Dave!

The topic ‘Two function join results to 1 table’ is closed to new replies.