Forum Discussion
LCicio
Jan 22, 2024Copper Contributor
Sharepoint Copy Folder and Permissions
I've been searching and haven't found anything what I need to be able to do is copy a folder that has permissions set, this folder will also have sub folders with their own permissions set. I want to...
DenzilJamesGreenwood
Jan 23, 2024Copper Contributor
See if this works:
Create a New Flow in Power Automate:
Go to Power Automate and create a new automated flow.
Choose the appropriate trigger depending on when you want this copy action to occur. For instance, you can use a trigger like "When a file is created or modified" in a SharePoint folder.
Get Folder Metadata:
Add an action to get the metadata of the folder you want to copy. This includes its permissions.
You might need to use the SharePoint "Get folder metadata" or "Get file metadata" actions.
Copy the Folder:
Use the "Create new folder" action to create a folder at the destination. This step doesn't copy the contents yet, just creates a new folder.
Copy the Contents:
Add actions to copy the contents of the original folder to the new folder. This might be complex if you have nested folders and a large number of files.
You might need to use a combination of "Get files (properties only)" and "Copy file" actions.
Replicate Permissions:
This is the tricky part. Power Automate doesn't have a straightforward action to copy permissions.
You'll likely need to use the SharePoint REST API within Power Automate to handle permissions. This can be done using an HTTP action to send a request to the SharePoint API.
You need to fetch the permission levels of the original folder and then apply these to the new folder using the API.
Iterate for Subfolders (if needed):
If there are subfolders with unique permissions, you'll have to repeat the process for each subfolder.
This can be done by adding a loop in your flow that iterates through each subfolder.
Testing and Validation:
Test your flow thoroughly to ensure it's copying both the files and permissions correctly.
Pay special attention to edge cases like large folders, deeply nested structures, or unique permission setups.
Create a New Flow in Power Automate:
Go to Power Automate and create a new automated flow.
Choose the appropriate trigger depending on when you want this copy action to occur. For instance, you can use a trigger like "When a file is created or modified" in a SharePoint folder.
Get Folder Metadata:
Add an action to get the metadata of the folder you want to copy. This includes its permissions.
You might need to use the SharePoint "Get folder metadata" or "Get file metadata" actions.
Copy the Folder:
Use the "Create new folder" action to create a folder at the destination. This step doesn't copy the contents yet, just creates a new folder.
Copy the Contents:
Add actions to copy the contents of the original folder to the new folder. This might be complex if you have nested folders and a large number of files.
You might need to use a combination of "Get files (properties only)" and "Copy file" actions.
Replicate Permissions:
This is the tricky part. Power Automate doesn't have a straightforward action to copy permissions.
You'll likely need to use the SharePoint REST API within Power Automate to handle permissions. This can be done using an HTTP action to send a request to the SharePoint API.
You need to fetch the permission levels of the original folder and then apply these to the new folder using the API.
Iterate for Subfolders (if needed):
If there are subfolders with unique permissions, you'll have to repeat the process for each subfolder.
This can be done by adding a loop in your flow that iterates through each subfolder.
Testing and Validation:
Test your flow thoroughly to ensure it's copying both the files and permissions correctly.
Pay special attention to edge cases like large folders, deeply nested structures, or unique permission setups.