Powershell script to move onedrive folder to Another folder

TejalKatkar-5562 1 Reputation point
2022-09-27T06:47:00.613+00:00

Hello Team,

Require kind assistance, i have onedrive folder "Personal Data" , need to move all the contents of this folder ( like files/folders/subfolders etc) to another folder within same OneDrive called "Documents"

This needs to be performed for more than 100 Users. could you please assist if we have any script for the same.

Checked below script & trying to modify it as per my requirement :

https://www.sharepointdiary.com/2018/08/sharepoint-online-move-all-files-from-one-folder-to-another-using-powershell.html

Microsoft 365 and Office | SharePoint | Development
Microsoft 365 and Office | OneDrive | For business | Windows
{count} votes

1 answer

Sort by: Most helpful
  1. Xyza Xue_MSFT 30,241 Reputation points Microsoft External Staff
    2022-09-28T02:44:45.277+00:00

    Hi @TejalKatkar-5562 ,
    When you make any changes to a document (files/folders/subfolders) in sites, OneDrive will automatically update the changes you made in a very short time. So to move OneDrive "Personal Data" folder to "Document" folder, you just need to move site level "Personal Data" folder to "Document" folder using powershell. "OneDrive will be updated automatically.
    Here is my test result, I use PnP PowerShell code to move the "Personal Data" folder in the document library to the "Document" folder, and OneDrive automatically moves the "Personal Data" folder to the " Document" folder.
    245230-image.png
    245343-image.png
    PnP PowerShell code:245344-movefolder.txt


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.