Saturday, 5 November 2016

Download All solutions (wsp files) in Sharepoint


Today I am providing the Power Shell Script that will download all solutions (wsp file) in Local SharePoint Farm in the given folder and Also save their status in a txt file.

Inputs
Path - The path where you want to save all the custom solutions.

Outputs
This script will download all solutions (wsp file) in Local SharePoint Farm in the given folder.

Example-
.\scriptname.ps1
.\scriptname.ps1 | out-file “FilePath\Filename.txt”

Dependencies -
For executing this script user must be added in site collection administrators given site.
User should have Shell Admin rights to run the scripts.
Run Management Shell as an Administrator. 
How to execute -
Copy this script and paste in Note pad.
Save this file as .ps1.
Run this script in SharePoint Management Shell.
Follow on screen instructions.

FOR ANY HELP ON THIS SCRIPT USE "GET-HELP .\SCRIPTNAME.PS1 --FULL" AFTER SAVING THIS FILE.


Go to above link to get the script.

Clear Cache of all severs in one go

Today I am providing the Power Shell Script that will clear the cache configuration from all SharePoint servers in one go.

You have to provide all server names of the farm in the script. Provide individual server names inside double coutos ("), and separated by coma as shown in the script itself and Modify the script and provide the Server names. For getting GUID for configuration go to following path in registry editor of any one server (app or wfe). Here copy the GUID and provide it as input when asked by the script. "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\15\Secure\ConfigDB" for SharePoint 2013 or "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\14\Secure\ConfigDB" for Sharepoint 2010

You can also follow this path in any one server (app or wfe) of the farm “C:\ProgramData\Microsoft\SharePoint\Config” and look for a folder which contains XML files and one cache.ini file. And provide this folder path to the script. This GUID is same for all servers in a Farm.

Inputs
Cache GUID - you can get this GUID from "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\15\Secure\ConfigDB" for SharePoint 2013 or "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\14\Secure\ConfigDB" for Sharepoint 2010

Outputs
This script will clear the cache configuration from all SharePoint servers in one go

Example-
.\scriptname.ps1
.\scriptname.ps1 | out-file “FilePath\Filename.txt”

Dependencies -
For executing this script user must be added in site collection administrators given site.
User should have Shell Admin rights to run the scripts.
Run Management Shell as an Administrator. 
How to execute -
Copy this script and paste in Note pad.
Save this file as .ps1.
Run this script in SharePoint Management Shell. You can run this script in PowerShell as well.
Follow on screen instructions.


FOR ANY HELP ON THIS SCRIPT USE "GET-HELP .\SCRIPTNAME.PS1 --FULL" AFTER SAVING THIS FILE.
https://drive.google.com/file/d/0BznVpoE_ln0Ac0RsUlhBQml0YjA/view?usp=sharing
Go to above link to get the script.

Creating a Site Collection using script

Today I am providing the Power Shell Script that create a Site collection “host named” or normal on the given web application on the given database.

Inputs
Site collection URL : Provide the new site collection URL.
HostHeader Web Application (Optional): Provide the webapplication URL that will host this collection(in case of Hosted Site Collection). This is optional field and can be left blank if you have provided the webapplication URl in the Site collection.
Database Name (Optional): Provide Database name where you want to move above site collection. Database must already exists in web application. This is optional field.
Site name : Provide Site Collection Name
Description (Optional) : Provide Site Collection Description
Site template : Provide Site template that will be used to create the site
Primary Login : Primary user name (Primary Site Collection Administrator)
Site Primary email (Optional) : Primary administrator email if any.
Secondary Login (Optional) : Secondary user name (Secondary Site Collection Administrator)
Secondary email (Optional) : Secondary administrator email if any.

Outputs
This script will Create a new site collection on the given database on the given web application.

Example-
.\scriptname.ps1
.\scriptname.ps1 | out-file “FilePath\Filename.txt”

Dependencies –
if you are creating a site collection on specific Database then database must exists in the given webapplication.
if you are creating hosted site collection then you have to follow additional steps from this url. http://hostnamedsc.blogspot.in/2016/05/host-named-site-collection-is-not.html
For executing this script user must be added in site collection administrators given site.
User should have Shell Admin rights to run the scripts.
Run Management Shell as an Administrator.
How to execute -
Copy this script and paste in Note pad.
Save this file as .ps1.
Run this script in SharePoint Management Shell. You can run this script in PowerShell as well.
Follow on screen instructions.

FOR ANY HELP ON THIS SCRIPT USE "GET-HELP .\SCRIPTNAME.PS1 --FULL" AFTER SAVING THIS FILE.
Go to above link to get the script.



Creating Content Database on a given Web application

Today I am providing the Power Shell Script that create content database for a given web application on the given server.

Inputs
Web Application : Provide the webapplication URL where you want a new database.
Database Name : Provide new Database name.
SQL Server : SQL server where new database will be created.

Outputs
This script will Create new content database for a given webapplication on a given SQL server.

Example-
.\scriptname.ps1
.\scriptname.ps1 | out-file “FilePath\Filename.txt”

Dependencies –
SharePoint Farm Admin must have DBCreator rights on the SQL server if you are creating Database on different server other than SharePoint Farm Server.
For executing this script user must be added in site collection administrators given site.
User should have Shell Admin rights to run the scripts.
Run Management Shell as an Administrator.
How to execute -
Copy this script and paste in Note pad.
Save this file as .ps1.
Run this script in SharePoint Management Shell. You can run this script in PowerShell as well.
Follow on screen instructions.

FOR ANY HELP ON THIS SCRIPT USE "GET-HELP .\SCRIPTNAME.PS1 --FULL" AFTER SAVING THIS FILE.
Go to above link to get the script.



Granting permissions on SharePoint objects


Today I am providing the Power Shell Script that give permissions on Item level to the users or groups that are provided in a csv file. This csv will take the csv file as input. The structure of csv file will contain following columns - WebsiteURL,Libraryinternalname,Itemname,user_group,permissions,type,removeexistingpermission
Here in type you have provide the type of the object - Site, Library, Folder, Item
and In removeexistingpermission you have provide if you want to remove existing permissions in the form of True/False.
Sample file is also provided in the blog. Provide items and their permission individually in the csv.

Update - For the items  or folder that are under some folder structure, provide complete structure like "rootfolder1/subfolder2/subfolder3/item.ext". You can provide multiple user/group names and multiple permissions for the same item in one row separated by a comma. Create csv file using Ms Excel else you have to put "" for providing multiple user names and permissions like "user1,user2","permission1,permission2". All the permissions will be granted to all the users in one row on the given Item. if you want to give different permissions for different users then add them in different rows.

You can provide different sites, different libraries in one go to provide the permissions to their items in one go.

Inputs
This script will take path of csv file as input. Further this csv file will be used as input.

Outputs
This script will give the permission to the users  on the items  

Example-
.\scriptname.ps1
.\scriptname.ps1 | out-file “FilePath\Filename.txt”

Dependencies -
Input CSV file must be ready for the script.
Item names should be provided with extension. For folder names leave extensions.
Permission levels/Groups/Users must be available in sharepoint.
For executing this script user must be added in site collection administrators given site.
User should have Shell Admin rights to run the scripts.
Run Management Shell as an Administrator. 


How to execute -
Copy this script and paste in Note pad.
Save this file as .ps1.
Run this script in SharePoint Management Shell. You can run this script in PowerShell as well.
Follow on screen instructions.

FOR ANY HELP ON THIS SCRIPT USE "GET-HELP .\SCRIPTNAME.PS1 --FULL" AFTER SAVING THIS FILE.
https://drive.google.com/file/d/0BznVpoE_ln0AQzRtb1dVMi1JV00/view?usp=sharing

To see and download csv template file click here.
https://drive.google.com/file/d/0BznVpoE_ln0AdjdkcC1XeWFlT1U/view?usp=sharing

Go to above link to get the script.

Modify the Site url of content type hub in Managed Metadata service application

Today I am providing the Power Shell Script that can be used to modify the Site url for content type hub in managed meta data service application.

We can not modify the url of content type hub using UI once we have defined that in Managed Metadata Service Application. Use below script for doing this.

Inputs
Managed Metadata Service Application - Name of the Managed Metadata Service Application that is using the content type hub.
Site url - URL of the site that will host the content types.

Outputs
This Script will Change the URL of Content type hub in Managed Metadata Service Application.

Example-
.\scriptname.ps1
.\scriptname.ps1 | out-file “FilePath\Filename.txt”

Dependencies –
For executing this script user must be added in site collection administrators in the sites.
User should have Shell Admin rights to run the scripts.
Run Management Shell as an Administrator.
How to execute -
Copy this script and paste in Note pad.
Save this file as .ps1.
Run this script in SharePoint Management Shell. You can run this script in PowerShell as well.
Follow on screen instructions.

FOR ANY HELP ON THIS SCRIPT USE "GET-HELP .\SCRIPTNAME.PS1 --FULL" AFTER SAVING THIS FILE.


Go to above link to get the script.

Delete Site/site collections in bulk

Today I am providing the Power Shell Script that will delete multiple sites/site collections from the given list. List will be provided in the form of a csv file. The columns in csv file will be siteurl, type. Here in type, Provide s if given url is for sub site or sc for site collection.

.Inputs
Path - Provide csv file with path that will be used as input for this script.

.Outputs
Sites will be deleted as per the list in csv file.

Example-
.\scriptname.ps1
.\scriptname.ps1 | out-file “FilePath\Filename.txt”

Dependencies –
For executing this script user must be added in site collection administrators in the sites.
User should have Shell Admin rights to run the scripts.
Run Management Shell as an Administrator.
How to execute -
Copy this script and paste in Note pad.
Save this file as .ps1.
Run this script in SharePoint Management Shell. You can run this script in PowerShell as well.
Follow on screen instructions.

FOR ANY HELP ON THIS SCRIPT USE "GET-HELP .\SCRIPTNAME.PS1 --FULL" AFTER SAVING THIS FILE.


Go to above link to get the script.
Csv template link –