Combine Two Different Objects

Welcome Forums General PowerShell Q&A Combine Two Different Objects

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

 
Participant
1 week, 4 days ago.

  • Author
    Posts
  • #181638

    Participant
    Topics: 11
    Replies: 16
    Points: 138
    Rank: Participant

    Hello,

    I'm looking to combine/match results from two different object sets.  The first one is from 'Get-PowerBIReport' has the following output:

    
    Id : 12573cbf-77ab-42c4-b915-6
    Name : PBPhone
    WebUrl : https://app.powerbi.com/reports/12573cbf-77ab-42c4-b915-6
    EmbedUrl : https://app.powerbi.com/reportEmbed?reportId=12573cbf-77ab-42c4-b915-6762bf51cfab&config=ey
    XJsIjoiaHR0cHM6Ly9XQUJJLVVTLUVBU1QyLXJlZGlyZWN0LmFuYWx5c2lzLndpbmRvd3MubmV0In0%3d
    DatasetId : 971a8a6e-f465-4e42-b2b8
    
    

    The other is from 'Get-PowerBIDataset' and has the following output:

    
    Id : 29a26268-8b33-4de5-be90-63
    Name : server_count_example
    ConfiguredBy :
    DefaultRetentionPolicy :
    AddRowsApiEnabled : False
    Tables :
    WebUrl :
    Relationships :
    Datasources :
    DefaultMode :
    IsRefreshable : True
    IsEffectiveIdentityRequired : False
    IsEffectiveIdentityRolesRequired : False
    IsOnPremGatewayRequired : True
    
    

    Is there anyway to match the results?  I'd also like to add a third object from a different get statement.

    Thanks,

    Frank

  • #181665

    Participant
    Topics: 8
    Replies: 1213
    Points: 756
    Helping Hand
    Rank: Major Contributor
    • #181890

      Participant
      Topics: 11
      Replies: 16
      Points: 138
      Rank: Participant

      I tried something similar, but not quite the linq query. I created an empty array to collect the objects, but I still seem to be missing data.

      $outputCollection = @()
      $reports = Get-PowerBIReport -Scope Organization 
      $datasets = Get-PowerBIDataset -Scope Organization
      
      $reports | Foreach-Object {
          #Associate objects
          $reportObject = $reports
          $datasetObject = $datasets | Where-Object {$_.Id -eq $reportObject.Id}
      
          #Make a combined object
          $outputObject = "" | Select Name, ConfiguredBy, MailboxAttribute
          $outputObject.Name = $reportObject.Name
          $outputObject.ConfiguredBy = $reportObject.ConfiguredBy
          $outputObject.ID = $datasetObject.Id
      
          #Add the object to the collection
          $outputCollection += $outputObject
      }
      
      $outputCollection
      

      The output:

      
      Name             : {Dashboard Usage Metrics Report, Office 365 Adoption Preview, Office 365 
                         Adoption Preview, Microsoft Azure Consumption Insights...}
      ConfiguredBy     : 
      ID: 
      
      

      I'm still missing the link between reports and datasets?

      Thanks,
      Frank

You must be logged in to reply to this topic.