Hi
I am trying to download from documents from Sharepoint to a windows folder. The scrip works in ISE but not when running from the command line (using administrator). The script is:-
$SharePointSiteURL = "https://sueryder.sharepoint.com/sites/Document Hub/H%26SC%20Performance%20Management%20Data/"
$O365ServiceAccount = "sharepoint.download@xyz.org"
$O365ServiceAccount1 = "xyz"
[SecureString]$Secure = ConvertTo-SecureString $O365ServiceAccount1 -AsPlainText -Force
[System.Management.Automation.PSCredential]$PSCredentials = New-Object System.Management.Automation.PSCredential($O365ServiceAccount, $Secure)
Add-PnPStoredCredential -Name $SharePointSiteURL -Username $PSCredentials.UserName -Password $Secure
Connect-PnPOnline -Url $SharePointSiteURL -Credentials $PSCredentials