[英]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:
因此,这是我最终为获取链接所做的事情:
Here is an example 这是一个例子
$UniqueID = (Get-PnPListItem -id 231 -List Budget).FieldValues.UniqueID $ UniqueID =(Get-PnPListItem -id 231-列表预算).FieldValues.UniqueID
the $UniqueID = e1a1f20f-4b7d-4y16-x021-3469bde98088 $ UniqueID = e1a1f20f-4b7d-4y16-x021-3469bde98088
Here are the link steps: 以下是链接步骤:
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.