Created
October 2, 2021 04:02
-
-
Save plamber/76f305b6cf847733f067ed8dff7f3528 to your computer and use it in GitHub Desktop.
Retrieve the Known Folder Move Directories from a OneDrive site
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ### Example on how to retrieve the Known Folder Move Directories from a OneDrive site | |
| ### This script is using PNP PowerShell to perform the activity | |
| $url = "OneDriveUrl" | |
| Connect-PnPOnline $url | |
| function Get-FolderUrl ($context, $list, $valueToCheck) { | |
| if ($list.RootFolder.Properties.FieldValues.ContainsKey($valueToCheck)) { | |
| $item = $list.GetItemByUniqueId($list.RootFolder.Properties.FieldValues[$valueToCheck]) | |
| $context.Load($item) | |
| $context.ExecuteQuery() | |
| return $item["FileRef"] | |
| } | |
| return "" | |
| } | |
| $context = Get-PnPContext | |
| $list = Get-PnPList "Documents" | |
| $context.Load($list.RootFolder.Properties) | |
| $context.ExecuteQuery() | |
| [pscustomobject]@{ | |
| "onedriveUrl" = $url | |
| "desktopFolderRelativeUrl" = Get-FolderUrl $context $list "vti_DesktopFolderGuid" | |
| "documentsFodlerRelativeUrl" = Get-FolderUrl $context $list "vti_DocumentsFolderGuid" | |
| "photosFolderRelativeUrl" = Get-FolderUrl $context $list "vti_PhotosFolderGuid" | |
| "cameraFolderRelativeUrl" = Get-FolderUrl $context $list "vti_CameraRollFolderGuid" | |
| "screenshotsFolderRelativeUrl" = Get-FolderUrl $context $list "vti_ScreenShotsFolderGuid" | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment