Sharepoint links into OneDrive #3942
Unanswered
codeiswork
asked this question in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I'm following a process to set this up and get down to the creation of the shortcut and it fails.
Command is this:
Add-PnPFile -Folder $odFolderUrl -SourceURL $spFolderUrl -Values @{LinkingUrl=$spFolderUrl; LinkingDisplayName=$odShortcutName} -ShortcutUrl=$spFolderUrl
Output is this:
Add-PnPFile : Parameter set cannot be resolved using the specified named parameters.
At line:1 char:1
What am I missing?
Install the SharePointPnPPowerShellOnline module
Install-Module SharePointPnPPowerShellOnline -Force -AllowClobber -Scope CurrentUser -WarningAction Ignore
Import the SharePointPnPPowerShellOnline module
Import-Module SharePointPnPPowerShellOnline
Define the SharePoint Online domain
$domain = "checksmart"
Define the SharePoint Online URL
$spSiteName = "FSTestAccounting"
$spSiteUrl = "https://$domain.sharepoint.com/sites/$spSiteName"
Connect to SharePoint Online using the current user's credentials
Connect-PnPOnline -Url $spSiteUrl -useWebLogin -WarningAction Ignore
Get the current connection context
$spConnection = Get-PnPConnection
Check if the connection is null
if ($null -eq $spConnection) {
Write-Output "Not connected."
} else {
Write-Output "Connected to $($spConnection.Url)."
}
Get a specific library by its title - most SP sites seem to have 'Documents'
$spLibraryTitle = "Documents"
$spLibrary = Get-PnPList -Identity $spLibraryTitle
Check if the library exists
if ($null -eq $spLibrary) {
Write-Output "Library '$spLibraryTitle' not found."
} else {
Write-Output "Library '$spLibraryTitle' found."
}
get the relative path to the library
$spLibraryUrl = $spLibrary.RootFolder.ServerRelativeUrl
Write-Output "'$spLibraryTitle' relative URL is: '$spLibraryUrl'"
Find a single folder by its name
To find a named folder, you need the full path of the folder relative to the $siteUrl
$spFolderName = $spLibraryUrl
+"/path/to/my/folder"
$spFolder = Get-PnPFolder -URL $spFolderName
Check if the folder exists
if ($null -eq $spFolder) {
Write-Output "Folder '$spFolderName' not found."
} else {
Write-Output "Folder '$spFolderName' found."
}
get the server relative folder URL
$spFolderUrl = $spFolder.ServerRelativeUrl
Define the target OneDrive folder URL based on current user's name
Given the '-my' suffix on the domain, a second connection is needed.....
$username = [Environment]::USERNAME
$username = $username -replace '.', '_'
$odSiteUrl = "https://$domain-my.sharepoint.com/personal/"+$username+"_domain_com"
Connect to SharePoint Online using the current user's credentials
Connect-PnPOnline -Url $odSiteUrl -UseWebLogin -WarningAction Ignore
Get the current connection context
$odConnection = Get-PnPConnection
Check if the connection is null
if ($null -eq $odConnection) {
Write-Output "Not connected."
} else {
Write-Output "Connected to $($odConnection.Url)"
}
Get a specific library by its title
# In OneDrive, there is typically only one document library called "Documents". This is where all your files and folders are stored.
$odLibraryTitle = "Documents"
$odLibrary = Get-PnPList -Identity $odLibraryTitle
Check if the library exists
if ($null -eq $odLibrary) {
Write-Output "Library '$odLibraryTitle' not found."
} else {
Write-Output "Library '$odLibraryTitle' found."
}
get the relative path to the library
$odLibraryUrl = $odLibrary.RootFolder.ServerRelativeUrl
Write-Output "'$odLibraryTitle' relative URL is: '$odLibraryUrl'"
Try to put the link in the root folder
$odFolderUrl = $odLibraryUrl
Get-Help Add-PnPFile -Detailed
Create a OneDrive shortcut to the SharePoint folder
$odShortcutName = "Shortcut to $spFolder.Name"
Add-PnPFile -Folder $odFolderUrl -SourceURL $spFolderUrl -Values @{LinkingUrl=$spFolderUrl; LinkingDisplayName=$odShortcutName} -ShortcutUrl=$spFolderUrl
disconnect
Disconnect-PnPOnline
Beta Was this translation helpful? Give feedback.
All reactions