PnP-PowerShell
PnP-PowerShell copied to clipboard
Decode SharePoint Online Sharing links
Reporting an Issue or Missing Feature
Issue/Question
Expected behavior
This is more of a question than a suggestion. I'm looking for a CSOM or a REST API that would allows me to decode any kind of a SharePoint sharing link. For example, if you got to a modern UI library to get the link of document, you may be presented with something like this: https://contoso.sharepoint.com/:i:/r/sites/someweb/SiteAssets/cats.jpg?csf=1&e=L9eqe2 This may not look too bad but sharing/anon links are a lot more cryptic.
As a developer, I should be able to decode any links generated by SharePoint (and therefore provided to my app/service/function via a user) in order to get the file's actual path and content.
Actual behavior
If I supply a link that I've obtained from the SP Online Modern UI interface and feed it as a URL param to Get-PnPFile, I will not get a valid SPFile object. I'm using a PowerShell cmdlet as an example here but other PnP libraries or _api calls will result in a failure.
Are there any APIs that would allow me to decode a valid SharePoint links that users may supply to my solution?
Steps to reproduce behavior
- Get a link to a file from a SharePoint Online Modern UI library
- Try to obtain content or field information using SharePoint APIs with the link obtained in step 1
Which version of the PnP-PowerShell Cmdlets are you using?
- [ ] PnP PowerShell for SharePoint 2013
- [ ] PnP PowerShell for SharePoint 2016
- [x] PnP PowerShell for SharePoint Online
What is the version of the Cmdlet module you are running?
3.10
How did you install the PnP-PowerShell Cmdlets?
- [ ] MSI Installed downloaded from GitHub
- [x] Installed through the PowerShell Gallery with Install-Module
- [ ] Other means
Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.
This has become a big issue with my user community now they realise that a share will overide the 'as designed' permissions.
IT need to be able to advise and revert where necessary
Has there been any movement on this feature request? This is something that many organizations would likely require or benefit from. We're in the process of migrating a large amount of content from Classic sites to Modern pages and many of the older pages reference images via a sharing link rather than the item's URL. We've attempted to leverage invoke-webrequest to capture the 302 redirect with the location header which contains the items real path, but so far that's been unsuccessful.
@flyinaroundpdx I raised this as a question and it seems the lack of activity suggests that there is no way of doing this with public APIs. I'd advise you to look for a similar User Voice feature request and up-voting it or raise one yourself. Or just try to get out of SharePoint development as it is a massive dumpsterfire (that's the path I'm on 🙃)