Managing Power Platform Connectors using PowerShell

Loading

Power Platform connectors enable communication between Power Automate, Power Apps, and external services like SharePoint, Dataverse, and Azure. Using PowerShell, you can list, manage, enable, disable, and delete connectors within your environment.


Step 1: Install and Import Required PowerShell Modules

Before running any commands, ensure that you have the necessary PowerShell modules installed.

# Install Power Platform PowerShell modules if not already installed
Install-Module -Name Microsoft.PowerApps.Administration.PowerShell -Scope CurrentUser -Force
Install-Module -Name Microsoft.PowerApps.PowerShell -Scope CurrentUser -Force

# Import the modules
Import-Module Microsoft.PowerApps.Administration.PowerShell
Import-Module Microsoft.PowerApps.PowerShell

Step 2: Connect to Power Platform

To manage connectors, you must authenticate using an administrator account.

# Connect to Power Platform
Add-PowerAppsAccount

For service principal authentication:

$AppId = "YOUR_APP_ID"
$TenantId = "YOUR_TENANT_ID"
$CertificateThumbprint = "YOUR_CERT_THUMBPRINT"

Connect-AdminPowerAppEnvironment -ApplicationId $AppId -TenantId $TenantId -CertificateThumbprint $CertificateThumbprint

Step 3: List All Available Connectors

To retrieve a list of all connectors in an environment:

# Get all environments
$environments = Get-AdminPowerAppEnvironment

# Select a specific environment (Modify as needed)
$envId = ($environments | Where-Object { $_.DisplayName -eq "Your Environment Name" }).EnvironmentName

# List all connectors in the environment
$connectors = Get-AdminPowerAppConnector -EnvironmentName $envId

# Display the connectors
$connectors | Format-Table DisplayName, ConnectorId, IsCustom, CreatedTime

Step 4: Get Details of a Specific Connector

To fetch details about a specific connector:

$connectorId = "YOUR_CONNECTOR_ID"

# Retrieve details of the specified connector
$connectorDetails = Get-AdminPowerAppConnector -EnvironmentName $envId -ConnectorId $connectorId
$connectorDetails

Step 5: Enable or Disable a Connector

You can disable or enable a connector to restrict or allow usage.

# Disable a connector
Disable-AdminPowerAppConnector -EnvironmentName $envId -ConnectorId $connectorId

# Enable a connector
Enable-AdminPowerAppConnector -EnvironmentName $envId -ConnectorId $connectorId

Step 6: Remove a Connector

To delete an unused or unauthorized connector:

Remove-AdminPowerAppConnector -EnvironmentName $envId -ConnectorId $connectorId -Confirm:$false

Step 7: Export Connector Information

To export all connector details to a CSV file:

$connectors | Select-Object DisplayName, ConnectorId, IsCustom, CreatedTime | Export-Csv -Path "C:\PowerPlatform\Connectors.csv" -NoTypeInformation

Step 8: Disconnect Session (Optional)

After managing connectors, disconnect from Power Platform:

Disconnect-AdminPowerAppEnvironment

Leave a Reply

Your email address will not be published. Required fields are marked *