I am not able to connect to sharepoint using below script
$Mycredentials = Import-Clixml -Path “file1.xml”
Connect-PnPOnline -Url $SiteUrl -Credentials $Mycredentials
Add-PnPFile -Folder “folder1” -Path “file2.csv”
I am not able to connect to sharepoint using below script
$Mycredentials = Import-Clixml -Path “file1.xml”
Connect-PnPOnline -Url $SiteUrl -Credentials $Mycredentials
Add-PnPFile -Folder “folder1” -Path “file2.csv”
Can you post the error message?
Connect-PnPOnline : Object reference not set to an instance of an object.
At line:12 char:1
Add-PnPFile : Cannot contact site at the specified URL Sign in to your account. The app principal does not
exist.
At line:21 char:1
Deleted.
<Objs Version=“1.1.0.1” xmlns=“http://schemas.microsoft.com/powershell/2004/04”>
<Obj RefId=“0”>
<TN RefId=“0”>
<T>System.Management.Automation.PSCredential</T>
<T>System.Object</T>
</TN>
<ToString>System.Management.Automation.PSCredential</ToString>
<Props>
<S N=“UserName”>abc@mic.net</S>
<SS N=“Password”>5aebd577fb6a140000006c4a0eb6f61bb18e6d200d7c8d3ee98685587b9d</SS>
</Props>
</Obj>
</Objs>
Also the account is set to use MFA.
CAn that be an issue?
I can connect to sharepoint with useWeblogin fine.
I think MFA requires the -UseWebLogin switch. From the docs:
If you want to connect to SharePoint with browser based login. This is required when you have multi-factor authentication (MFA) enabled.
The xml file is fine. Try adding this switch to your Connect-PnPOnline command.