On-Premises Data Gateway Monitoring using PowerShell


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

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s