$username = "amos@contoso.onmicrosoft.com" $password = "Password" $cred = New-Object -TypeName System.Management.Automation.PSCredential -argumentlist $userName, $(convertto-securestring $Password -asplaintext -force) $Url = "https://contoso.sharepoint.com/sites/dev" Connect-PnPOnline -Url $Url -Credentials $cred $ctx = Get-PnPContext $authenticationCookies = $ctx.credentials.GetAuthenticationCookie($Url) Write-Host $authenticationCookies