【问题标题】:Download a specific file from a group in Sharepoint at Office 365 with powershell使用 powershell 从 Office 365 的 Sharepoint 中的组下载特定文件
【发布时间】:2017-06-29 09:08:07
【问题描述】:

我是这个 Powershell / Office365 / SharePoint 的新手,所以这就是我在这里寻求帮助的原因。我正在处理的问题是:我在 Office365 上的 SharePoint 组中。几个人之间共享了一个文档,该文档更改了该文档中的内容。我想定期将此文档下载到我的本地计算机。

我认为,最好的方法是使用 PowerShell 来完成这项任务。但到目前为止,我只能使用 PowerShell 登录 Office365:

Set-ExecutionPolicy RemoteSigned
Import-Module Msonline
$mycred = Get-Credential
$session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "https://ps.outlook.com/powershell/" -Credential $mycred -Authentication Basic -AllowRedirection
Import-PSSession $session
Connect-MsolService -Credential $mycred

问题是:现在该怎么办?当我在谷歌上搜索时,有很多不同的脚本,每个人都在使用其他似乎不是我想要的功能。我也没有找到关于这个主题的任何好的教程。

编辑

PhilC 的回答帮助了一点,但还是少了点什么,出现了一些问题。

这是我在后面部分之后添加的附加内容:

$sharepointURL="https://somesharepoint-my.sharepoint.com/"
$SPOUSer="myuser@email.com"
$SPOPassword="sometestingpassword"

// ...

[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client");
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client.Runtime");
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client.Taxonomy");

// ...

$ctx = New-Object Microsoft.SharePoint.Client.ClientContext($sharepointURL)
$ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($SPOUser,$SPOPassword);

if (!$ctx.ServerObjectIsNull.Value) {
    Write-Host "Connected to SharePoint Online site: '$sharepointURL'" -ForegroundColor Green
}

Write-Host "Load Web ..."
$web = $ctx.Web
$ctx.Load($web)
$ctx.ExecuteQuery()

Write-Host "Load file ..."
$file = $ctx.Web.GetFileByServerRelativeUrl("/personal/myuser_email_com/Documents/test1.docx")
$ctx.Load($file)
$ctx.ExecuteQuery()

但是这里出现了一些问题:

  1. 我是否需要同时登录 Office365 和 SharePoint?

  2. 当我运行这个脚本时,我得到这个错误信息:Exception calling "ExecuteQuery" with "0" argument(s): "Access denied. Sie haben keine Berechtigung, diesen Vorgang auszuführen oder auf diese Ressource zuzugreifen" 看来,我没有执行这个操作的权限或者我不能访问这个资源。我做错了什么吗?这是我在 Office365 中创建的文件。我需要额外的权利吗?顺便说一句,我不是管理员,负责管理用户等等。

附加说明:对于第二个脚本,我想创建一个小示例,用于从我的文档中下载文件,然后再执行下一步并从与我共享的 SharePoint 组下载文件。

【问题讨论】:

标签: powershell sharepoint download office365 document


【解决方案1】:

【讨论】:

  • 这个链接确实有帮助。但还有一些问题。我将编辑我最初的问题。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-09-08
  • 2022-08-05
  • 2022-10-25
  • 2013-09-22
  • 1970-01-01
  • 2020-09-22
相关资源
最近更新 更多