Reply
Topic Options
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe to Topic
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
10-16-2020
02:42 AM
Script for loading files from SharePoint doesn't work on WS 2012 R2 (MFA)
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 ?
Labels:
- Labels:
-
Server Solutions
-
Windows & Devices
1 REPLY 1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
10-16-2020
07:35 AM
When the user account has MFA enabled and when the script should run automated, I guess the only option is to use an App (Service principal) with app only permissions: https://www.sharepointdiary.com/2019/03/connect-pnponline-with-appid-and-appsecret.html
Though, I would advice to use certificates, not the app secret in a production environment - but the general approach is quite well described in there.
Kind regards, Janosch
Receive consultations via Technical Presales and Deployment Services team
Receive consultations via Technical Presales and Deployment Services team
