Get an alert before connections expire and flows fail

Get an alert before connections expire and flows fail

By:

Date:

Have you had flow connection expire? For example when your flow owners use MFA and it is time to re-authenticate?

Broken connections

Fix connection in Power Automate

Would you like to get alerted before you get to the Fix Connection situation?

PowerApps and Flow PowerShell might be able to help you.

(Get-AdminPowerAppConnection).Internal.properties

The above command gives you all your connections.

apiId : /providers/Microsoft.PowerApps/apis/shared_onedriveforbusiness
displayName : Pieter.Veenstra@company.co.uk
iconUri : https://az818438.vo.msecnd.net/icons/onedriveforbusiness.png
statuses : {@{status=Error; target=token; error=}}
connectionParameters : @{sku=Enterprise}
keywordsRemaining : 38
createdBy : @{id=e41a2ef4-3c91-4d41-a2ee-5baa222baafe; displayName=Pieter Veenstra; email=Pieter.Veenstra@company.co.uk; type=User; tenantId=c9bb0321-d7ee-4269-93cc-935cbfef6278;
userPrincipalName=Pieter.Veenstra@company.co.uk}
createdTime : 2017-12-08T16:17:07.6285488Z
lastModifiedTime : 2018-09-24T14:29:58.7781845Z
expirationTime : 2018-03-12T17:37:13.1183723Z
testLinks : {@{requestUri=https://europe-001.azure-apim.net/apim/onedriveforbusiness/b7da6808a2923cda91e94760a6a670fa/testconnection; method=get}}
environment : @{id=/providers/Microsoft.PowerApps/environments/Default-c9bb0321-d7ee-4269-93cc-935cbfef6278; name=Default-c9bb0321-d7ee-4269-93cc-935cbfef6278}

All your connections will show as connected except for the failed one. But we want to catch the problems before they happen.

To make sure that you only get the failed connections you could even go for something like this:

(Get-AdminPowerAppConnection -EnvironmentName "Default-c9bc0321-d7ee-4269-93cc-935cbfef6278").Internal.properties | Where { $_.statuses -like "*Error*"}

Once you’ve got the list of connections that need to be fixed, sending out an alert should be easy.

Ok, So I didn’t get to the BEFORE a connection expires but at least I can get fairly close to the connection having expired.

Using Power Automate instead

Would you like to use Power Automate instead of Powershell? Have a look at the following post:

Broken Connections Using Power Automate

Is your business still running on paper trails, sprawling Excel files, or ageing Access databases? There’s a better way — and I can show you exactly what it looks like. I’m the Technical Director of Vantage 365, a Microsoft solutions consultancy working with clients across the UK, the Netherlands, and worldwide. For over 30 years I’ve been turning messy, manual business processes into clean, automated systems that save time, reduce errors, and give teams the visibility they need to make better decisions. SharePains is not just any blog run by a Microsoft MVP. Have you ever used Try-Catch in Power Automate? The original post about Try-Catch in Power Automate can still be found on this site, https://staging.sharepains.com/2018/02/07/try-catch-finally-in-power-automate-flow/ Or have you ever used the Pieter’s method to avoid variables and speed up your flows? https://staging.sharepains.com/2020/03/11/pieters-method-for-advanced-in-flows/ You can contact me using contact@staging.sharepains.com

2 responses to “Get an alert before connections expire and flows fail”

  1. Kong Y Avatar
    Kong Y

    Hi good morning. I used this powershell admin command with a service account but I didn’t get any values returned. Do you know why? Thanks!

    1. Pieter Veenstra Avatar

      What do you get if you run just:

      Get-AdminPowerAppConnection

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.