I been trying several versions but this is the closest I got so far.
The attached ps1 script works almost...
2025-03-19 07:01:47 Script started.
2025-03-19 07:01:47 Modules imported successfully.
2025-03-19 07:01:47 Successfully retrieved Azure AD App credentials.
2025-03-19 07:01:47 Successfully retrieved on-premises credentials (MyDomain\SyncUser).
2025-03-19 07:01:48 Successfully retrieved OAuth access token.
2025-03-19 07:01:48 Authenticated to Microsoft Graph successfully via Service Principal.
2025-03-19 07:01:48 First user in tenant: Contoso Atlanta (obscured original name here)
2025-03-19 07:01:48 Converted on-premises credentials to PSCredential.
2025-03-19 07:01:48 Failed to initialize AzureADSSO Authentication Context: The authority (including the tenant ID) must be in a well-formed URI format.
Parameter name: authority
If there are better ways to do this automated... I am listening