So this is the script that I have -
the SPO side is done and confirmed working.
The ITGlue API Key the same

The issue in the line of code I have here is regarding the Unify login.
Unify just enforced MFA on all accounts and the code in the script does not account for that part, can anybody provide me some insight ?

The steps to the link was followed as per this link
Sync UniFi Sites with IT Glue - GCIT

# UniFi Details

$UnifiBaseUri = "https://unifi.yourdomain.com:8443"

$UnifiCredentials = @{

username = "EnterUnifiAdminUserNameHere"

password = "EnterUnifiAdminPasswordHere"

remember = $true

} | ConvertTo-Json

I think if you want the script to handle MFA your going to need to adjust the way authentication is handled. If you have any documentation on the UniFi API have a look through that to se who it handles MFA as it might tell you how to get this via your script. You could even try, if UniFi supports API keys, set one of these up that has restricted permissions that bypass MFA for automated tasks, which could be a simpler and secure solution. I think it might be best to adapt the script to handle authentication tokens instead of plain username/password and make sure your script can refresh tokens or re-authenticate as needed without manual intervention.