Viewing a SharePoint folder, there is a button for "Add Shortcut to OneDrive". Clicking that creates a OneDrive Shortcut, indicated by a folder icon with a blue link decoration on it, in OneDrive MyFiles.

If I have a web link for a SharePoint folder, is there a way to programmatically create a OneDrive Shortcut from the link?

A limitation is that I cannot create an Azure AD app. I'm currently using the following to leverage the current user credentials for all calls;

Connect-PnPOnline -Url $odSiteUrl -UseWebLogin -WarningAction Ignore

GH CoPilot suggests this code, which does not work at all:

Add-PnPFile -Folder $odFolderUrl -SourceUrl $spFolderUrl -Values @{LinkingUrl=$spFolderUrl; LinkingDisplayName=$odShortcutName} -ShortcutUrl

`$odFolderUrl` is the OneDrive folder I want to create the link in
`$spFolderUrl` is the Sharepoint folder I want to link to
`$odShortcutName` is name I want the shortcut folder to have
  • CoPilot suggested you to create a simple shortcut file and store it in a folder within SharePoint. Mayby this module is what you are looking for: github.com/derpenstiltskin/onedriveshortcuts Commented Nov 28, 2023 at 8:19
  • @Christoffer - Thanks for the suggestion. onedriveshortcuts requires that "To use this module you need to create an Azure AD application." Unfortunately, that's a stone cold dead non-starter for my organization. I'm using Connect-PnPOnline -Url $odSiteUrl -UseWebLogin to use the logged in user's credentials for all calls.
    – CAB
    Commented Nov 28, 2023 at 22:19


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.