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"
$webUrl
= "siteurl"
$username
= "ankur@company.com"
$password = Read-Host -Prompt "Password
for " -AsSecureString
$cred = New-Object -TypeName System.Management.Automation.PSCredential -argumentlist $username
, $password
$onlineCred = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($username
, $password)
$c = $onlineCred.GetAuthenticationCookie($webUrl
)
$c
In the end you will get the cookie string if you have proper access.