Here is the version for connecting to Exchange online: Connect to Exchange Online PowerShell (Please note, basic is disabled for Exchange online, you need to enable basic for remote PowerShell first)
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection
If you don't want to enable basic for Exchange online, you will need to connect to Exchange with modern auth.
Import-Module ExchangeOnlineManagement
Connect-ExchangeOnline -UserPrincipalName <UPN>
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.