How to List SharePoint Subfolders and Their Sharing Links?

0
12
Asked By CuriousCoder92 On

Hey everyone! I'm in the process of tidying up a SharePoint site that's become a bit chaotic. It's mainly used for sharing files with external users, and I want to run a PowerShell script to accomplish a few tasks:

1. List all the subfolders under a specified folder.
2. Get the sharing link for each of these subfolders.
3. Identify the external email addresses that have access via those links.

I'm currently using PowerShell 7 along with PnP PowerShell v2.1.2. I'm trying to utilize the `Get-PnPFolderSharingLink` command, but I'm having trouble getting it to work properly. Here's the command I tried:

`Get-PnPFolderSharingLink -FolderUrl "Shared Documents/Folder/Subfolder"`

However, I'm getting this error: **Get-PnPFolderSharingLink: A parameter cannot be found that matches parameter name 'FolderUrl'.**

Has anyone managed to do something similar or have tips on how to approach this? I appreciate any help!

2 Answers

Answered By HelpfulHarry88 On

Hey! It looks like you're on the right track but might need to adjust the command a bit. Instead of using `-FolderUrl`, try just `-Folder` without the parameter. For example, use `Get-PnPFolderSharingLink -Folder "Shared Documents/Folder/Subfolder"`. That should help!

QuestionAsker -

Thanks for the tip, but I still ran into the same error! It's really frustrating.

Answered By AdviceAce74 On

From what you've described, it seems like you fixed the parameter issue but now you're facing an authentication problem. Have you considered setting an environment variable before connecting? You could add something like:

```powershell
$env:ENTRAID_APP_ID = ''
Connect-PnPOnline "https://yourtenant.sharepoint.com" -Interactive
```

This could help resolve the access token error you're seeing!

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.