you can store the credential in credential manager on Windows and then provide them when you connect
Connect-PnPOnline -Url http://yourlocalserver -Credentials 'O365Creds'
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi, i have a short ps script to download a file from SharePoint with MFA.
$SiteURL = "https://sharepoint.com/sites/..."
$FileRelativeURL = "/../....docx"
$DownloadPath = "C:\Temp"
Try {
#Connect to PNP Online
Connect-PnPOnline -Url $SiteURL -UseWebLogin
# download file
Get-PnPFile -Url $FileRelativeURL -Path $DownloadPath -AsFile
}
catch {
write-host "Error: $($_.Exception.Message)" -foregroundcolor Red
}
it's working fine on my PC, but on Win server 2012 R2 it's still asking to confirm account and loading file.
I am using azure synchronize account. Could someone help to figure it out ?
you can store the credential in credential manager on Windows and then provide them when you connect
Connect-PnPOnline -Url http://yourlocalserver -Credentials 'O365Creds'
@Micki ,
You could refer to the following script to connect to SharePoint sites :
$username = " ****** "
#<the full email address of a SharePoint administrator account, example: jdoe@contosotoycompany.onmicrosoft.com>
$siteUrl = "https://sp/sites/test"
$FileRelativeURL = "/.../.../Test.docx"
$DownloadPath = "C:\Temp"
Try {
#Connect to PNP Online
$credential = Get-Credential -UserName $username -Message "Type the password:"
Connect-PnPOnline -Url $siteUrl -Credentials $credential
# download file
Get-PnPFile -Url $FileRelativeURL -Path $DownloadPath -AsFile
}
catch {
write-host "Error: $($_.Exception.Message)" -foregroundcolor Red
}
You could refer to this article Connect-PnPOnline to learning more command to connect to SharePoint.
Thanks,
Echo Du
==========
If an Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.