Bulk Upload Files to SharePoint remotely using CSOM


I am using this script: https://gallery.technet.microsoft.com/PowerShell-Bulk-Upload-b9e9d600

But every time i run it i am getting this message ““The remote server returned an error: (403) Forbidden.””

I think it is something to do with how the credentials are getting passed into Sharepoint Office 365 which has changed since the script was updated in 2015.

After looking for four hours this morning i can not figure it out, if anyone can help me would be seriously appreciated please ripping my hair out.

In the script the only bit i changed was adding:

Add-Type -Path “C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll”

Add-Type -Path “C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll”