Thursday, October 27, 2016

Copy Permissions from One SharePoint Site to Another using PowerShell

Requirement: Copy permissions from one site to another in SharePoint!

Solution: If you want to copy one SharePoint site to another site, there is no OOTB ways! However, You can use PowerShell to copy permissions between sites. Here is my PowerShell script to copy site permissions.

copy permissions from one sharepoint site to another using powershell

Copy Permissions from one site to another using PowerShell:
Add-PSSnapin Microsoft.SharePoint.PowerShell -erroraction SilentlyContinue
#PowerShell Function to copy permissions from one site to another
Function Copy-SitePermissions()
 Try {
  #Set the Error Action
    $ErrorActionPreference = "Stop"
  #Get the Source and Target Webs
  $SourceWeb = Get-SPWeb $SourceWebURL
  $TargetWeb = Get-SPWeb $TargetWebURL
  #if permissions are Inherited in the target, Break it!
   #Reset the Inheritence in Target Web
   #Copy permissions from Source to Target Web
     $SourceWeb.RoleAssignments | foreach-object {
    Write-Host "Permissions copied from Source Site to the Target!" -f Green
 catch {
   Write-Host $_.Exception.Message -ForegroundColor Red
 finally {
  #Reset the Error Action to Default
  $ErrorActionPreference = "Continue"

#Call the function to copy Web permissions 
Copy-SitePermissions -SourceWebURL "" -TargetWebURL "" 

You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.

Check out these SharePoint products:

1 comment :

  1. Hi,

    I am getting the following error on using the above code: Exception calling "Add" with "1" argument(s): "0x80070003". please let me know, how to fix this?


Please Login and comment to get your questions answered!

You might also like:

Related Posts Plugin for WordPress, Blogger...