'Powershell PnP - Login to Sharepoint Online with given credentials
I have found that using PnP is more suitable for me, but I am struggeling to automatically log in for running some scripts periodically. Previously without PnP I have used following code:
$Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
$Ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($user,$pass)
to login, where $pass is some long string generated from the password and converted to SecureString. But how to do the same with PnP login without haveing to play around with certificates or some AppSecret stuff?
If duplicate, please give me a hint! Thank you!
Solution 1:[1]
You can refer to following script to log in sharepoint online
$SiteURL="https://xxx.sharepoint.com"
$UserName="[email protected]"
$Password = "password"
$SecurePassword = ConvertTo-SecureString -String $Password -AsPlainText -Force
$Cred = New-Object -TypeName System.Management.Automation.PSCredential -argumentlist $UserName, $SecurePassword
#connect to sharepoint online site using powershell
Connect-PnPOnline -Url $SiteURL -Credentials $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 |
|---|---|
| Solution 1 | RaytheonXie-MSFT |
