Photo past times Karly Santiago at Unsplash
This is 1 of the snippets I ever forget, exactly which is really handy inwards cases where yous accept the absolute URL to an special inwards SharePoint. The magic is actually work half-dozen which uses the static method WebUrlFromFolderUrlDirect to larn the spider web URL of the file, in addition to thence that yous tin connect properly.
$uri = [Uri]'https://contoso.sharepoint.com/sites/foo/bar/Shared%20Documents/mikael-is-cool.docx' # Connect to the beginning site, or whatsoever other site Connect-PnPOnline -Url ($uri.Scheme+'://'+$uri.Host) $ctx = Get-PnPContext # Get the spider web url for the file $webUrl = [Microsoft.SharePoint.Client.Web]::WebUrlFromFolderUrlDirect($ctx, $uri) Connect-PnPOnline -Url $webUrl $fileItem = Get-PnPFile -Url $uri.AbsolutePath -AsListItemThanks for reading : How To Become The Listing Detail From A File Url Using Pnp Powershell