0

目前正在寻找一台专门用于任务计划程序和 excel 的计算机,以在线将文件上传到 Sharepoint。不过我的问题。有没有办法设置一个自动脚本,使用特定的用户帐户连接到在线共享点?

4

1 回答 1

1

您需要在运行脚本的计算机上安装 SharePoint Server 2013 客户端组件 SDK 。

下面演示了如何在 PowerShell 中通过 CSOM 连接到 SharePoint Online:

$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

您可以在此处找到使用 CSOM 将文件上传到文档库的 PowerShell 脚本

于 2014-03-26T09:35:36.523 回答