Created
August 26, 2024 18:13
-
-
Save grenzi/166b81aaf72740eb4c267173465cfb02 to your computer and use it in GitHub Desktop.
See if power bi on-prem data gateways are happily running / available, using a service principal account
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Import-Module MicrosoftPowerBIMgmt | |
$clientId="REDACTED" | |
$tenantId="REDACTED" | |
$clientSecret="REDACTED" | |
$securePassword = ConvertTo-SecureString -String $clientSecret -AsPlainText -Force | |
$credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $clientId, $securePassword | |
Connect-PowerBIServiceAccount -ServicePrincipal -Credential $credential -TenantId $tenantId | |
$gwlist = Invoke-PowerBIRestMethod -Url gateways -Method Get | ConvertFrom-Json | |
foreach ($gateway in $gwlist) { | |
$gwid = $gateway.value.Id | |
$gw = Invoke-PowerBIRestMethod -Url "gateways/{$gwid}" -Method Get | ConvertFrom-Json | |
if (-not "Live" -eq $gw.gatewayStatus){ | |
#your code here for when the gateway is not showing all ok | |
write-host "panic oh noes" | |
} | |
} | |
Disconnect-PowerBIServiceAccount |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment