I'm trying to download files being edited in Microsoft Teams/Sharepoint Online using various examples from the Internet (including the ones here). Currently I am using the Sharepoint PnP module: https://docs.microsoft.com/en-us/powershell/module/sharepoint-pnp/?view=sharepoint-ps
But all I am getting is "Get-PnPFile : File Not Found."
$cn = Connect-PnPOnline -Url $Site -ReturnConnection
Get-PnPFile -AsFile -Connection $cn -Url $Url -FileName $FileName -Path $Path
I am using the link to a file (that people are collaborating in Teams on) copied from the Sharepoint website (following the link from Teams, then getting the link from the file itself) which comes in the form https://oursite.sharepoint.com/:x:/s/foldernamefromteams/longidentifier I've tried passing that Url with and without the site name. I don't get an error on the Connect line. It pops up the username and password prompt.
I think the key is getting the site and/or URL correct, but I don't know how to get the correct URL other than from the link that Sharepoint says is the link to the file. Pasting that link in the browser does open the Excel sheet (or whatever) for editing in the browser, instead of downloading the file, but I'm not sure what a more "direct" link would be, or how to get it.
https://oursite.sharepoint.com
from the url...