How to migrate selected folder and files permission from OneDrive to Sharepoint Online?

%3CLINGO-SUB%20id%3D%22lingo-sub-1622373%22%20slang%3D%22en-US%22%3EHow%20to%20migrate%20selected%20folder%20and%20files%20permission%20from%20OneDrive%20to%20Sharepoint%20Online%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1622373%22%20slang%3D%22en-US%22%3E%3CP%3EWe%20are%20migrating%20all%20the%20permission%20of%20selected%20contents(files%20and%20folders)%20from%20the%20OneDrive%20to%20SharePoint%20Online%2C%20if%20number%20of%20files%20are%20less%20than%20100%2C%20script%20migrate%20it's%20in%20half%20an%20hour%2C%20however%2C%20if%20the%20count%20of%20files%20more%20than%205000%20then%20it%20will%20takes%20around%2010%20hours%2C%20which%20is%20effecting%20the%20performance%20of%20migration.%3C%2FP%3E%3CP%3EKindly%20find%20below%20the%20portion%20of%20code%20for%20getting%20the%20permissions.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3E%23%24fileUrl%20-NewFolder%2Flogo.png%0A%24file%20%3D%20Get-PnPFile%20-Url%20%24fileUrl%20-AsListItem%0AGet-PnPProperty%20-ClientObject%20%24file%20-Property%20RoleAssignments%0A%24members%20%3D%20Get-PnPProperty%20-ClientObject%20%24roleAssignments%20-Property%20RoleDefinitionBindings%2C%20Member%0A%24member%20%3D%20%24roleAssignments.Member%0A%23list%20of%20users%0A%24Users%20%3D%20Get-PnPProperty%20-ErrorAction%20SilentlyContinue%20-ClientObject%20%24member%20-Property%20Users%0A%23Return%20Accesstype%0A%24accessType%20%3D%20%24roleAssignments.RoleDefinitionBindings.Name%3B%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%3C%2FP%3E%3CP%3EHence%2C%20we%20are%20decide%20to%20use%20workflow%20in%20the%20PowerShell%20script%2C%20as%20shown%20in%20the%20below%20link%3A%3C%2FP%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fgist.github.com%2Fjamiekt%2Ff586e47cb96b93dacbe5%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fgist.github.com%2Fjamiekt%2Ff586e47cb96b93dacbe5%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EBut%20this%20link%20doesn't%20fulfil%20our%20requirement.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EKindly%20let%20us%20any%20suitable%20solution%20in%20the%20PowerShell%20to%20meet%20our%20requirement%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1622373%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EPowerShell%20ISE%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
New Contributor

We are migrating all the permission of selected contents(files and folders) from the OneDrive to SharePoint Online, if number of files are less than 100, script migrate it's in half an hour, however, if the count of files more than 5000 then it will takes around 10 hours, which is effecting the performance of migration.

Kindly find below the portion of code for getting the permissions.

 

#$fileUrl -NewFolder/logo.png
$file = Get-PnPFile -Url $fileUrl -AsListItem
Get-PnPProperty -ClientObject $file -Property RoleAssignments
$members = Get-PnPProperty -ClientObject $roleAssignments -Property RoleDefinitionBindings, Member
$member = $roleAssignments.Member
#list of users
$Users = Get-PnPProperty -ErrorAction SilentlyContinue -ClientObject $member -Property Users
#Return Accesstype
$accessType = $roleAssignments.RoleDefinitionBindings.Name;

               

Hence, we are decide to use workflow in the PowerShell script, as shown in the below link:

https://gist.github.com/jamiekt/f586e47cb96b93dacbe5

 

But this link doesn't fulfil our requirement.

 

Kindly let us any suitable solution in the PowerShell to meet our requirement

0 Replies