Skip to content

Commit

Permalink
Automated download of Power BI template report
Browse files Browse the repository at this point in the history
  • Loading branch information
Dave Ruijter authored and Dave Ruijter committed Sep 18, 2020
1 parent 9dbaa83 commit 81a4f4c
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 15 deletions.
Binary file modified BPAA insights.pbit
Binary file not shown.
43 changes: 28 additions & 15 deletions BPAA.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ $PowerBIServicePrincipalClientId = Read-Host -Prompt 'Specify the Application (C
$PowerBIServicePrincipalSecret = Read-Host -Prompt 'Specify the secret of the Service Principal' -AsSecureString
$PowerBIServicePrincipalTenantId = Read-Host -Prompt 'Specify the tenantid of the Service Principal'

# Download URL for Tabular Editor portable (you can leave this default, or specify another version):
$BPAATemplateReportDownloadUrl = "https://github.com/DaveRuijter/BestPracticeAnalyzerAutomation/raw/master/BPAA%20insights.pbit"

# =================================================================================================================================================

# TODO:
Expand All @@ -55,12 +58,13 @@ $PowerBIServicePrincipalTenantId = Read-Host -Prompt 'Specify the tenantid of th
# =================================================================================================================================================

function Get-ScriptDirectory {
if ($psise) {
Split-Path $psise.CurrentFile.FullPath
}
else {
$global:PSScriptRoot
}
#if ($psise) {
# Split-Path $psise.CurrentFile.FullPath
#}
#else {
# $global:PSScriptRoot
#}
$OutputDirectory
}

# Couple of functions to help call the .exe
Expand Down Expand Up @@ -140,14 +144,14 @@ else {
}
}

# Download destination (root of this PowerShell script path):
Write-Host "=================================================================================================================================="

# Specify download destination of Tabular Editor:
$TabularEditorPortableRootPath = Join-Path -Path $(Get-ScriptDirectory) -ChildPath "\TabularEditorPortable"
new-item $TabularEditorPortableRootPath -itemtype directory -Force | Out-Null
$TabularEditorPortableDownloadDestination = Join-Path -Path $TabularEditorPortableRootPath -ChildPath "\TabularEditor.zip"
$TabularEditorPortableExePath = Join-Path -Path $TabularEditorPortableRootPath -ChildPath "\TabularEditor.exe"

Write-Host "=================================================================================================================================="

# Download portable version of Tabular Editor from GitHub:
Write-Host 'Downloading the portable version of Tabular Editor from GitHub...'
Invoke-WebRequest -Uri $TabularEditorUrl -OutFile $TabularEditorPortableDownloadDestination
Expand All @@ -163,6 +167,15 @@ $TabularEditorBPARulesPath = Join-Path -Path $TabularEditorPortableRootPath -Chi
Invoke-WebRequest -Uri $BestPracticesRulesUrl -OutFile $TabularEditorBPARulesPath
Write-Host 'Done.'

# Specify download destination of the Power BI template report:
$TemplateReportRootPath = Join-Path -Path $(Get-ScriptDirectory) -ChildPath "\"
new-item $TemplateReportRootPath -itemtype directory -Force | Out-Null
$TemplateReportDownloadDestination = Join-Path -Path $TemplateReportRootPath -ChildPath "\BPAA insights.pbit"

# Download BPAA Template report from GitHub:
Write-Host 'Downloading the template Power BI report from GitHub...'
Invoke-WebRequest -Uri $BPAATemplateReportDownloadUrl -OutFile $TemplateReportDownloadDestination

Write-Host "=================================================================================================================================="

# Connect to the Power BI Service
Expand Down Expand Up @@ -226,15 +239,15 @@ if ($workspaces) {
Write-Host "=================================================================================================================================="
}

Write-Host 'Outputting all datasets info to disk...'
Write-Host 'Outputting all metadata of the datasets to disk...'
$datasetsOutputPath = Join-Path -Path $OutputDirectory -ChildPath "\$CurrentDateTime\BPAA_datasets.json"
$biglistofdatasets | ConvertTo-Json -Compress | Out-File -FilePath $datasetsOutputPath

Write-Host "Script finished."

# Open Power BI template file
$PBITLocation = Join-Path -Path $(Get-ScriptDirectory) -ChildPath "\BPAA insights.pbit"
Invoke-Item $PBITLocation
Write-Host "Open Power BI template file..."
Invoke-Item $TemplateReportDownloadDestination

Write-Host "Script finished."

# Stop tracing errors
# Stop tracing
Stop-Transcript

0 comments on commit 81a4f4c

Please sign in to comment.