简体   繁体   English

如何使用Powershell从SharePoint Online文档库中的文档获取“复制链接”

[英]How can I get the “Copy Link” from a document on SharePoint Online document library using Powershell

I'm looking for a way to get the link that you get when you press copy link on a document from sharepoint online document library. 我正在寻找一种方法,当您从Sharepoint联机文档库中按文档上的复制链接时,获得该链接。 I need to retrieve this link programmatically using powershell. 我需要使用powershell以编程方式检索此链接。 any advice and thoughts? 有什么建议和想法吗?

Here is a picture of the link highlighted in blue. 这是以蓝色突出显示的链接的图片。

在此处输入图片说明

Thank you 谢谢

You need to use the Microsoft Graph API. 您需要使用Microsoft Graph API。 There are examples and documentation around the web but it is in Beta so keep in mind the process might change. 网上有示例和文档,但是它们处于Beta中,因此请记住该过程可能会更改。

You can use Get on the sharepoint site and see the drive objects, Then you can connect to them using the Drive ID and look at the webURL property of the files. 您可以在Get点站点上使用Get并查看驱动器对象,然后可以使用Drive ID连接到它们并查看文件的webURL属性。

https://developer.microsoft.com/en-us/graph/docs/api-reference/beta/resources/drive https://developer.microsoft.com/zh-CN/graph/docs/api-reference/beta/resources/drive

I ended up constructing the link dynamically. 我最终动态地构建了链接。 So Here is what I ended up doing to get the link: 因此,这是我最终为获取链接所做的事情:

  1. use the cmdlet Get-PnPListItem 使用cmdlet Get-PnPListItem
  2. retrieve each UniqueID for each item in the library 检索库中每个项目的每个UniqueID
  3. Here is an example 这是一个例子

    $UniqueID = (Get-PnPListItem -id 231 -List Budget).FieldValues.UniqueID $ UniqueID =(Get-PnPListItem -id 231-列表预算).FieldValues.UniqueID

  4. the $UniqueID = e1a1f20f-4b7d-4y16-x021-3469bde98088 $ UniqueID = e1a1f20f-4b7d-4y16-x021-3469bde98088

Here are the link steps: 以下是链接步骤:

  1. https://mycompany.sharepoint.com/Site/subsite/_layouts/15/WopiFrame.aspx?sourcedoc= { https://mycompany.sharepoint.com/Site/subsite/_layouts/15/WopiFrame.aspx?sourcedoc= {
  2. e1a1f20f-4b7d-4y16-x021-3469bde98088 e1a1f20f-4b7d-4y16-x021-3469bde98088
  3. }&action=edit }&action =编辑

at the end just construct all steps to build your link dynamically. 最后,只需构建所有步骤即可动态构建链接。 https://mycompany.sharepoint.com/Site/subsite/_layouts/15/WopiFrame.aspx?sourcedoc={e1a1f20f-4b7d-4y16-x021-3469bde98088}&action=edit https://mycompany.sharepoint.com/Site/subsite/_layouts/15/WopiFrame.aspx?sourcedoc={e1a1f20f-4b7d-4y16-x021-3469bde98088}&action=edit

In the end the only id you will be changing is the unique id between the curly brackets. 最后,您将要更改的唯一ID是花括号之间的唯一ID。

Adding to what Nick says, we can use the Graph API to achieve this requirement in particular the " createLink " endpoint. 除了Nick所说的以外,我们可以使用Graph API来实现此要求,尤其是“ createLink ”端点。

We can do a POST request with following body (or similar) 我们可以使用以下正文(或类似内容)发出POST请求

{
  "type": "edit",
  "scope": "organization"
}

and the request URL can be one of the following 并且请求URL可以是以下之一

  • /v1.0/sites/{site-id}/lists/{list-id}/items/{item-id}/driveItem/createLink /v1.0/sites/{site-id}/lists/{list-id}/items/{item-id}/driveItem/createLink
  • /v1.0/sites/{site-id}/drive/items/{drive-item-id}/createLink /v1.0/sites/{site-id}/drive/items/{drive-item-id}/createLink
  • /v1.0/sites/{site-id}/drives/{drive-id}/items/{drive-item-id}/createLink /v1.0/sites/{site-id}/drives/{drive-id}/items/{drive-item-id}/createLink

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用 PowerShell 为 SharePoint Online 中的文档库设置默认内容类型? - How can I setup default content type for a Document Library in SharePoint Online using PowerShell? 将文档库复制到文档库 sharepoint 在线与 powershell - Copy document library to document library sharepoint online with powershell 使用SharePoint Online PowerShell从模板创建文档库 - Create a Document Library from a Template using SharePoint Online PowerShell 使用 Powershell PNP 获取 Sharepoint 在线文档库中特定文件夹中的项目 - Get items in specific folder in Sharepoint online document library with Powershell PNP 使用PnP PowerShell for SharePoint Online在文档库上设置“说明” - Setting the “Description” on a Document Library using PnP PowerShell for SharePoint Online 使用 pnp 更新 SharePoint 在线文档库列属性 PowerShell - update SharePoint online document library column property using pnp PowerShell PowerShell 用于检索 SharePoint 在线文档库大小 - PowerShell for retrieving SharePoint Online Document Library Size 如何代表其他用户关注 SharePoint 文档库 (SharePoint online) 中的文档 - How to Follow document from SharePoint document library (SharePoint online) on behalf of other users 使用 powershell 从 SharePoint 文档库中提取数据到 CSV - extract data from SharePoint document library to CSV using powershell 在SharePoint中使用PowerShell从文档库中获取项目列表 - Getting a list of items from document library using PowerShell in SharePoint
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM