Get document by SharingDocId with Powershell

Occasional Contributor

Hi,

I found the hidden list "Sharing Links" on a SharePoint site. 

2020-01-15 10_16_41-Windows PowerShell ISE.png

It seems that all shared links are stored in this list. Now my question: How do I get to the shared document using this link? I assume that the SharingDocId references the document.
2020-01-15 10_17_41-Windows PowerShell ISE.png
Does anyone have an idea?
 
Bye 
Jens
1 Reply

@TheHailender 

SharingDocId is Document UniqueId of the Document/folder in the document libraries 

$SharingDocId = "<SharingDocId>"
$Ctx = Get-PnPContext
$file = $ctx.Web.GetFileById($SharingDocId)
$ctx.Load($file)
$ctx.ExecuteQuery()