Copy Files to Office 365 Groups with PowerShell

Office 365 Groups are a great upgrade on the traditional SharePoint Site/Shared Mailbox/Shared OneDrive folder/whatever you were previously using to share stuff. They’re a perfect candidate for migrating a department’s “network drive” (as the users would call it) to. Perhaps your HR department have S:\Human Resources, and Finance have S:\Finance. Or worse, perhaps HR have J:\ (or whatever the Service Desk person mapped it to) and Finance have X:\ (or some other drive). Groups are a great way of centralising file storage and making files accessible to approved users from wherever they happen to be.

In migrating large (several hundred GB) department file systems to Groups, after a bit of Googling and a bit of adding my own bits, I came up with the below script to allow an administrator (or even user, realistically) to copy a large volume of files to an Office 365 Group using PowerShell.

Getting Started

First, you’ll need to install the SharePoint Patterns & Practices SharePointPnP module. This can be installed using PowerShellGet on Windows 10:

Secondly, download the script to a folder on your computer by either selecting the text and saving it, or running the PowerShell code beneath it:

Thirdly, run the script with the appropriate parameters:

Done! Now it’ll run and copy your files up. Errors will need to be reviewed and remediated manually, though the PnP module does a pretty decent job of telling you what went wrong.

Caveats

  • This script (or, rather, the SharePoint Patterns & Practices module) doesn’t support moving files over 256 MB. You’ll need to move these manually based on the errors generated by this script
Written on February 20, 2018