首页 文章

如何使用powershell和(S)SOM将文件/目录上传到Office365中的sharepoint 2013?

提问于
浏览
1

我想启动一个新脚本,它接受一个本地文件路径和一个文档库名称,然后抓取该目录,并将找到的所有文件/文件夹上传到sharepoint 2014 office 365文档库(服务器端对象模型) ) .

我试过以下,但没有成功:

我们的租户在can - office 365我们正在使用sharepoint 2013我们希望能够查看文件夹,并使用文件夹结构获取所有文档,并通过powershell将结构和文件复制到我们的sharepoint租户 .

1 回答

  • 2

    您尝试过的链接使用的SharePoint服务器对象模型仅适用于本地SharePoint . 您需要SharePoint客户端对象模型才能使用SharePoint Online .

    Brendan Griffin发布了一篇文章,使用客户端对象模型和PowerShell将文件上传到SharePoint Online文档库:http://blogs.technet.com/b/fromthefield/archive/2014/02/19/office365-script-to-upload-files-to-a-document-library-using-csom.aspx

    以下是PowerShell代码的关键部分,其中在ClientContext上设置了SharePoint Online凭据:

    #Bind to site collection
    $Context = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
    $Creds = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($User,$Password)
    $Context.Credentials = $Creds
    

相关问题