-
Notifications
You must be signed in to change notification settings - Fork 44
/
Copy pathPowerBI_AuthenticateWithSpn.ps1
17 lines (15 loc) · 1.12 KB
/
PowerBI_AuthenticateWithSpn.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# =================================================================================================================================================
# Check if Power BI Module is available, if not install
# =================================================================================================================================================
$moduleName = Get-Module -ListAvailable -Verbose:$false | Where-Object { $_.Name -eq "MicrosoftPowerBIMgmt" } | Select-Object -ExpandProperty Name;
if ([string]::IsNullOrEmpty($moduleName)) {
Write-Host -ForegroundColor White "==============================================================================";
Write-Host -ForegroundColor White "Install module MicrosoftPowerBIMgmt...";
Install-Module MicrosoftPowerBIMgmt -SkipPublisherCheck -AllowClobber -Force
Write-Host -ForegroundColor White "==============================================================================";
}
# Define variables
$TenantId = "{YourTenantId}"
# Connect using SPN
Connect-PowerBIServiceAccount -ServicePrincipal -Credential (Get-Credential) -Tenant $TenantId
$ClientId = $SpInlog.ClientId