First you need to refer SharePoint client dlls Add-Type -Path "\\Microsoft.SharePoint.Client.dll" Add-Type -Path "\Microsoft.SharePoint.Client.Runtime.dll" #next pass the credentials and connect to web $siteURL = "" $userName = "" $PlainPassword = "" $password = $PlainPassword | ConvertTo-SecureString -AsPlainText -Force # set SharePoint Online credentials $SPOCredentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($userName, $password) #Creating client context object $clientContext = New-Object Microsoft.SharePoint.Client.ClientContext($siteURL) $clientContext.credentials = $SPOCredentials $web = $clientContext.Web $clientContext.load($web) $clientContext.executeQuery()