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" $siteURL = "https://contoso.sharepoint.com" $userId = "amos@contoso.onmicrosoft.com" $pwd = Read-Host -Prompt "Enter password" -AsSecureString $creds = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($userId, $pwd) $ctx = New-Object Microsoft.SharePoint.Client.ClientContext($siteURL) $ctx.credentials = $creds $authenticationCookies = $ctx.credentials.GetAuthenticationCookie($siteURL) Write-Host $authenticationCookies