Thursday 28 January 2016

How to backup and Restore Permission for Site Collection

Backup and Restore Permission for Site Collection.

Hi Friends,

Recently in my office some of colleagues provided me with set of deactivated user to be removed from SharePoint.this list contains some active users too unluckily...
which i had deleted and had no idea to restore this back..

So After Searching for the solution, i got a script to luck next time in future for any such incidence.

Please download the script from here.

These PowerShell scripts can backup and restore all your SharePoint Site Collections, Webs, Document Libraries, Folders and File.

This script does not backup permission for SPList and ListItem, It serves as a script to backup document related permission only

Backup Permission

How to use
How to run the backup script:
  1. Copy the BackupPermission.ps1 file to your SharePoint Server.
  2. Open SharePoint Management Shell via Administrator rights.
  3. Navigate to the BackupPermission.ps1 folder.
  4. Run BackupPermission.ps1 to start backing up all site collections.
  5. A Permissions.xml file will be generated in the same folder.

PowerShell Parameter:
  • -SiteUrl : Specify a URL to explicitly backup only a Site Collection
  • -Verbose : Execute in verbose mode where more information will be displayed and logged.

Restore Permission

How to run the backup script:
  1. Copy the RestorePermission.ps1 file and Permission.xml file that was generated after running BackupPermission.ps1, to the same folder in your SharePoint Server.
  2. Open SharePoint Management Shell via Administrator rights.
  3. Navigate to the RestorePermission.ps1 folder.
  4. Run RestorePermission.ps1.
  5. A list of affected Site Collection will be shown. Enter 'Y' or 'y' to continue.

PowerShell Parameter:
  • -Confirm : To bypass confirmation prompt.
  • -Verbose : Execute in verbose mode where more information will be display and logged.

Additional Configuration (script)

$global:includeFilePermission - Change this variable to $true to include File level permission and $false for otherwise.

Note: Each execution of the BackupPermission.ps1 and RestorePermission.ps1 will generate a log file in "Logs" sub-folder where the script sits.
You can modify the Permissions.xml file to change the behaviour of permission restore but make you have the XML syntax correctly formed

Wednesday 27 January 2016

Removing a user/users from all SharePoint Groups in a Site Collection

Removing a user/users from all SharePoint Groups in a Site Collection

For some SharePoint implementation, we might end up creating many SharePoint groups and add users to these groups based on the business needs. Later we might need to remove a user from all these groups or the entire site collection. If we are having many groups spread across various sub sites within the site collection, it will be a tedious task to manually remove the users from all the SharePoint groups. There are many blogs which talk about writing some PowerShell script to traverse through all the SharePoint Groups and remove the user/users. If you are trying to remove the user/users completely from the site collection and all its groups, you can do this is in a simple way through UI. No need to write any code or PowerShell. Follow the below steps. 

Simple and Powerful steps:
 
Step 1) - Login as Site Collection Administrator, click 'Site Actions' -> 'Site Settings'. 
 
Step 2) - Click on any exiting SharePoint Groups (eg., Memebers). This opens a new page, observe the URL of this page which will be something like below.
 
http://<<siteurl>>/_layouts/people.aspx?MembershipGroupID=5
  
Step 3) - Now, change the query string value of 'MembershipGroupID' to 0 (zero). This will show All People within the site collection.  
 
Step 4) - Select the user/users, and from the Actions menu click on 'Delete Users from Site Collection'
  This will remove the selected user/users from all the SharePoint groups, libraries, lists and sub sites in the Site Collection. 

Thanks and Enjoy :) :)

Wednesday 6 January 2016

SharePoint : Backup and Restore


Hi Friends, 


SharePoint is a popular enterprise application to enhanced collaboration. As the quantity and value of data stored in SharePoint platform arises. The need of backup and restore become critical for SharePoint Administrator.


Here are some option, which can help you in some critical scenarios


1. Restoring a Site Collection with PowerShell: 

After a site collection has been deleted, the Recycle Bin for the site is gone right along with the site collection.  Now, if the site collection was deleted through PowerShell or some other code, it cannot be restored using this method, but if it was deleted through the browser, then you can use this command to restore a Site Collection from the Recycle Bin by using PowerShell. 


1
Get-SPDeletedSite | Where-Object –Property URL –eq –Value “http://address.to.sitecollection/to/restore”) | Restore-SPDeletedSite

2. Use version history on lists and libraries


Enabling version history on lists and libraries is the other feature that will help your users be able to restore their own data. Version history keeps a copy of the documents and list items each time they are saved. Thanks to improvements in how SharePoint 2013 saves those changes, each saved version only uses space in the content database for the item changes. That’s right – the whole document isn’t saved again with each version of the document, which greatly reduces the impact on content database size.

Reverting back to a previous version of a file is easy and straightforward to the end users, and it makes you look like a superstar without you even doing anything.


3. Backing up sites, lists, and libraries


All of your Webs (the individual sites that make up your site collections), as well as the lists and libraries they contain, can be backed up either through Central Administration or through PowerShell.

You can find the Web backups in Central Administration under the Backup and Restore link on the Quick Launch navigation. From the Backup and Restore page, follow the Export a Site or List link under the Granular Backups heading.

If you’re going to use PowerShell, then you’ll want to use the Export-SPWeb cmdlet. This is a basic example using the two only required parameters – Identity (the Web to export) and Path (the file location):


1
Export-SPWeb –Identity “http://Sites/Projects/SharePoint2013” –Path “E:\Backups\SharePointProjectSite.cmp”


You may also want to get a backup a single site collection by using the Backup-SPSite cmdlet. Just as when you’re exporting a Web, you can get by with the basics:  – Identity and Path for your parameters.

Configure SharePoint settings to improve backup or restore performance



 1. You can only configure file compression and log file settings in Windows PowerShell. You can configure backup and restore threads in both the SharePoint Central Administration website and Windows PowerShell to increase backup or restore efficiency and performance.
 

If you use the Export-SPWeb Windows PowerShell cmdlet, you can use the NoFileCompression parameter. By default, SharePoint 2013 uses file compression while exporting web applications, site collection, lists, or document libraries. You can use this parameter to suppress file compression while exporting and importing. File compression can use up to 30% more resources. However, the exported file uses approximately 25% less disk space. If you use the NoFileCompression parameter when you export, you have to also use it when you import the same content. 


 2. You can also use the NoLogFile parameter. By default, SharePoint 2013 always cr

es a log file when you export content. Although you can use this parameter to suppress log file creation to save resources, we recommend that you always create logs. Logs are important for troubleshooting and log creation does not use many resources such as CPU or memory.


3. When you use the Backup-SPFarm cmdlet, you can also use the Backup Threads parameter to specify how many threads SharePoint 2013 will use during the backup process. A higher number of threads will consume more resources during backup. But the overall time to make the backup is decreased. Because each thread is recorded in the log files, the number of threads does affect log file interpretation. By default, three threads are used. The maximum number of available threads is 10. 


NoteNote:
The backup threads setting is also available through Central Administration on the Default Backup and Restore Settings page in the Backup and Restore section

C    Consider site collection size when you determine the tools to use


If the business requires site collection backups in addition to farm-level or database-level backups, choose a backup tool that is based on the size of the site collection.

1.  Less than 15 gigabytes (GB): Use the Backup-SPSite Windows PowerShell cmdlet. For more information, see Back up site collections in SharePoint 2013

 2. 15-100 GB: Use a SharePoint 2013 tool, a SQL Server tool, or other database backup tool to protect the content database that contains the site collection. For more information, see Back up site collections in SharePoint 2013.
 
ΓΌ  3. Larger than 100 GB: Use a differential backup solution, such as SQL Server 2008 R2 with SP1 or System Center 2012 - Data Protection Manager (DPM), instead of the built-in backup and recovery tools.