'When connecting to Sharepoint through Powershell Script, does the credential created via CLIXML fall under Modern Authentication?
Legacy auth is going away. I'm going to need to convert some scripts over to modern authentication. These are running daily tasks, so I don't want to have to login every time they need to execute and some are running against Office 365/Sharepoint Online Sites as well.
What are some best practices, if any, for making these run as intended, with complying under modern auth?
Can credential generated via Export-CLIXML (as per below powershell code) used in PSCredetial fall under Modern Authentication?
function Create-Site-Connection($siteUrl, $cred) {
Write-Host "Creating site connection : $siteUrl"
$connection = Connect-PnPOnline -Url $siteUrl -Credentials $cred
$ctx=Get-PnPContext
$title=$ctx.Web
$ctx.Load($title)
$ctx.ExecuteQuery()
Write-Host $title.Title
Write-Host "Created site connection : $siteUrl"
Disconnect-PnPOnline -Connection $connection;
}
Import-Module PnP.PowerShell
$cred = Import-CliXml -Path "C:\Work\ModernAuth\AuditSource.Cred"
Create-Site-Connection -siteUrl 'https://ABC.sharepoint.com/sites/xyz' -cred $cred
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
