Currently looking to have a computer soley dedicated to task scheduler and excel to upload files to Sharepoint online. My question though. Is there a way to set up a automated script that would connect to sharepoint online with a specific user account?

有帮助吗?

解决方案

You need the SharePoint Server 2013 Client Components SDK to be installed on the machine running the script.

Below is demonstrates how to connect to SharePoint Online via CSOM in PowerShell:

$UserName = "username@tenant.onmicrosoft.com"
$Url = "https://tenant.sharepoint.com/"
$Password = ""

Add-Type –Path "C:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.dll" 
Add-Type –Path "C:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Runtime.dll" 


if([string]::IsNullOrEmpty($Password)) {
   $SecurePassword = Read-Host -Prompt "Enter the password" -AsSecureString 
}
else {
   $SecurePassword = $Password | ConvertTo-SecureString -AsPlainText -Force
}



$Context = New-Object Microsoft.SharePoint.Client.ClientContext($Url)
$Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($UserName,$SecurePassword)
$Context.Credentials = $Credentials

You could find the PowerShell script for uploading files to a Document Library using CSOM here

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top