All credit for this goes to Roel van der Wegen More info : https://github.com/rvdwegen
This script can be used to create the Single Sign in App (https://halopsa.com/guides/article/?kbid=1189) required for the Azure Active Directory module in Halo PSA against all your customer tenants. It will first create the app, and then grant admin consent for it.
You will require a SAM app in your partner tenant, its secret, and a refresh token.