Office365 Cmd [best] -

$securePassword = ConvertTo-SecureString "client_secret" -AsPlainText -Force $cred = New-Object System.Management.Automation.PSCredential ("app@client-id", $securePassword) Connect-MgGraph -AccessToken (Get-MsalToken -ClientId "client-id" -TenantId "tenant-id" -ClientSecret "secret").AccessToken

office365 cmd