I have an authentication script below which is deemed as legacy and will soon be blocked by Microsoft.
How can I convert this script to use modern auth methods?
$site = https://mysite.sharepoint.com
$listName = "Events"
$user = [email protected]
$pwd = ConvertTo-SecureString "XXXXXXXXXXX" -AsPlainText -Force
$ctx = New-Object Microsoft.SharePoint.Client.ClientContext($site)
$credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($user,$pwd)
$ctx.Credentials = $credentials
$siteColl = $ctx.Web
$ctx.Load($siteColl)
$ctx.ExecuteQuery()