Hey everyone! I'm facing a bit of a puzzle with PowerShell. I'm trying to run a cmdlet to add a OneDrive URL to the exclusion list of a retention policy, but even though the URL works perfectly when I open it or add it manually through the GUI, it's throwing an error. The error says it's not a valid SharePoint location. Has anyone else run into this issue? Here's the command I'm using:
```
Connect-IPPSSession
Set-RetentionCompliancePolicy -Identity "MyPolicy" -RemoveOneDriveLocation "https://-my.sharepoint.com/:x:/r/personal/"
```
I would really appreciate any insights!
2 Answers
Make sure your OneDrive URL is formatted correctly. It should look like this: `https://contoso-my.sharepoint.com/personal/user_contoso_onmicrosoft_com/`. Replace "contoso" with your tenant name and "user" with the user's actual SAMAccountName. Also, check this article for more details: [OneDrive URLs](https://learn.microsoft.com/en-us/sharepoint/list-onedrive-urls). Good luck!
That error often means you may be using the wrong type of URL. What you have looks more like a sharing or mapped path rather than a direct OneDrive path. Make sure you're using the actual OneDrive URL, not the shared link.

I tried the correct URL format but still got the same error message. Any thoughts on what might be wrong?