You need the SharePoint Server 2013 Client Components SDK to be installed on the machine running the script.
Below is demonstrates how to connect to SharePoint Online via CSOM in PowerShell:
$UserName = "username@tenant.onmicrosoft.com"
$Url = "https://tenant.sharepoint.com/"
$Password = ""
Add-Type –Path "C:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type –Path "C:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
if([string]::IsNullOrEmpty($Password)) {
$SecurePassword = Read-Host -Prompt "Enter the password" -AsSecureString
}
else {
$SecurePassword = $Password | ConvertTo-SecureString -AsPlainText -Force
}
$Context = New-Object Microsoft.SharePoint.Client.ClientContext($Url)
$Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($UserName,$SecurePassword)
$Context.Credentials = $Credentials
You could find the PowerShell script for uploading files to a Document Library using CSOM here