Functions/Get-BsgPbiAllMappingFiles.ps1
<#
.SYNOPSIS Get all report and dataset mapping files from each workspace. .DESCRIPTION Get all report and dataset mapping files from each workspace. Please backup all workspaces before running this script. .PARAMETER Path The path to the tenant folder. The folder needs to include the workspaces and mapping files. .EXAMPLE # Get all mapping files Get-BsgPbiAllMappingFiles -Path "C:\temp\BSG PBI Administration" .INPUTS .OUTPUTS Returns an array of objects with the report and and datasets mappings. .NOTES #> function Get-BsgPbiAllMappingFiles { param( [Parameter(Mandatory=$true)][string]$Path ) try{ # Define paths and filenames $Path_Backup = Join-Path -Path $Path -ChildPath "Backup" $Path_Workspaces = Join-Path -Path $Path_Backup -ChildPath "Workspaces" $FileName_ReportDatasetMapping = "Mapping_ReportDataset.json" # Get workspace folder names $Source_Workspaces = Get-ChildItem -Path $Path_Workspaces -Name $AllDatasetReport_Mappings = @() foreach ($Source_WorkspaceName in $Source_Workspaces) { # Define paths and filenames $Path_Workspace = Join-Path -Path $Path_Workspaces -ChildPath $Source_WorkspaceName $Path_ReportDatasetMapping = Join-Path $Path_Workspace -ChildPath $FileName_ReportDatasetMapping # Check mapping file if (Test-Path $Path_ReportDatasetMapping){ # get mapping file for workspace $DatasetReport_Mapping = Get-Content -Path $Path_ReportDatasetMapping | ConvertFrom-Json -ErrorAction Stop # Add each report to overall mapping foreach ($report in $DatasetReport_Mapping) { $AllDatasetReport_Mappings += $report } } } return $AllDatasetReport_Mappings } catch{ Write-Host Stop-PSFFunction -Message "Could not get tenant mapping files." -EnableException $False -ErrorRecord $_ } } |