自动登录Sharepoint

时间:2014-03-26 04:00:48

标签: powershell sharepoint-2013 sharepoint-online

目前正在寻找一台专用于任务调度程序的计算机,并且擅长将文件上传到Sharepoint。我的问题。有没有办法设置一个自动脚本,可以通过特定的用户帐户在线连接到sharepoint?

1 个答案:

答案 0 :(得分:1)

您需要在运行脚本的计算机上安装SharePoint Server 2013 Client Components 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 here

将文件上传到文档库的PowerShell脚本