This blog post compliments a YouTube video that demonstrates how to monitor your Organization’s On-Premises Data Gateways using Powershell and Power Automate Desktop. Below are scripts that allow you to list the gateways (script #1) and then for a specific gateway, get its status (script #2). The complete video is linked below.
Script #1 – Get all on-Premises Data Gateways at the Organization Scope. Requires Power Platform or Tenant Admin to retrieve all values
$appId=$args[0]
$secret=$args[1]
$tenant=$args[2]
Get-Host | Select-Object Version
$secureString = ConvertTo-SecureString -String $secret -AsPlainText
Connect-DataGatewayServiceAccount -ApplicationId $appId -ClientSecret $secureString -Tenant $tenant
Install-Module -Name DataGateway -Force -Scope CurrentUser
Import-Module -Name DataGateway
Get-DataGatewayCluster -Scope Organization | Out-File -FilePath C:\temp\GatewayList.txt
Script #2 – Get the Status for a specific Gateway by providing the ID as a parameter. once again need to use Organization Scope
$appId=$args[0]
$secret=$args[1]
$tenant=$args[2]
$gatewayId = $args[3]
Get-Host | Select-Object Version
$secureString = ConvertTo-SecureString -String $secret -AsPlainText
Connect-DataGatewayServiceAccount -ApplicationId $appId -ClientSecret $secureString -Tenant $tenant
Install-Module -Name DataGateway -Force -Scope CurrentUser
Import-Module -Name DataGateway
Get-DataGatewayClusterStatus -Scope Organization -GatewayClusterId $args[3] | Out-File -FilePath C:\temp\CurrentGatewayStatus.txt