All credit for this goes to Roel van der Wegen More info : https://github.com/rvdwegen
This script can be used to create the Multi Tenant App (https://halopsa.com/guides/article/?kbid=1189) required for the CSP 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.