Monday, January 18, 2021

Change sharepoint site title and Description using Powershell

Here I am adding few PowerShell scripts in the upcoming blog post which all Sharepoint developer/admin will be using frequently. In each post I will add only code snippet in powershell so it will be easy to learn and remember Ashwell.

In this post I will provide the script to change the site title and description of the site.

Before that I want to make sure I am using Windows powershell ISE to run the script. We have option to run the script from VS code also.

Default location of PowerShell ISE will be available at the below location:

<%SystemRoot%>\System32\WindowsPowerShell\v1.0\PowerShell.exe

The discussion we are using here is meant for sharepoint 2013/16/19 not with Sharepoint Online(there is different way of using powershell for online and it will be discussed later)

As soon as we install sharepoint in the server, Powershell cmdlets available in the Management shell, here we dont need to install any other package to start working with this.

Note: All the required PS(Powershell) cmdlets will be available in Microsoft.SharePoint.PowerShell.dll

We can connect to sharepoint site, either using Sharepoint Management shell or Windows Powershell ISE(WPISE), if we are using WPISE then we need to register Microsoft.SharePoint.PowerShell.dll module for SharePoint Server cmdlets other wise we can skip this part.

Steps to add Snapin:

Add-PSSnapin Microsoft.SharePoint.PowerShell

Note: This needs to be added at the starting of the script, so that we wont get any error while executing the scripts:

Also there is another way we can register this as below(this is kind of good practice to follow)

$spSnapin = Get-PSSnapin | Where-Object {$_.Name -eq 'Microsoft.SharePoint.PowerShell'}
 if ($spSnapin -eq $null) {
Add-PSSnapin Microsoft.SharePoint.PowerShell }

In the above script we are making sure if the snapin is already available or not.

Who can run the script:

User who is running the script should have securityadmin role membership in SQL box also user should be part of Admin group.

How to open Sharepoint Management shell/Power ISE?

Its always good practice to open/run the shell with administration mode(run as admin)

Below is the script used to change the title and description of the site.

$Web= Get-SPWeb "http://sp2013"
$Web.Title = "Sharepoint 2013 Site"
$Web.Description = "Team site for Development"
$web.Update()



No comments:

Post a Comment