Learn some PowerShell SharePoint Commands in this tutorial. In any organization, they are mostly using the PowerShell command for all operations in SharePoint. Here I have explained a few commands which are mainly required for all SharePoint developer.
How to use PowerShell in SharePoint
If you are new to PowerShell, then you should know how to use PowerShell in SharePoint.
- SharePoint Online management shell: Check out this complete tutorial, if you want to work with SharePoint Online using PowerShell. It will explain, how to download, install and use SharePoint Online management shell to work with SharePoint Online.
- How to use PowerShell in SharePoint: Check out this article if you want to know how to use PowerShell in SharePoint on-premises versions like SharePoint 2013/2016/2019.
Below are the PowerShell SharePoint examples which we are going to discuss here. The commands will work in SharePoint On-premises versions like SharePoint 2019/2016/2013/2010.
For all the PowerShell SharePoint commands, I am using Windows PowerShell ISE or Visual Studio Code to run the PowerShell commands or scripts.
PowerShell SharePoint Commands
Now, let use see around 50 useful PowerShell SharePoint commands.
1. Create site collection using PowerShell in SharePoint
Below is the PowerShell SharePoint command or script to create a site collection using PowerShell in SharePoint. You may also like below SharePoint site collection tutorial:
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
#Configuration Variables
$SiteCollURL = "https://www.enjoysharepoint.com/sites/RajDemo"
$SiteName = "Welcome To Enjo SharePoint"
$SiteOwner = "HQAdmin\rswain"
$SiteTemplate = "STS#0" #Team Site Template
#Create new Site Collection
New-SPSite -URL $SiteCollURL -OwnerAlias $SiteOwner -Template $SiteTemplate -Name $SiteName
2. PowerShell create a site collection in a specific content database in SharePoint
Below is the PowerShell command to create a site collection in a specific content database in SharePoint. You may like the following SharePoint content database tutorials:
New-SPSite -Name "Welcome To Enjo SharePoint" -ContentDatabase SP2013_demo_Content -url https://www.enjoysharepoint.com/sites/RajDemo `-OwnerAlias "HQAdmin\rswain" -Template "STS#1"
3. Delete site collection PowerShell
Below is the PowerShell SharePoint Command to delete site collection PowerShell in SharePoint.
Remove-SPSite -Identity "https://www.enjoysharepoint.com/sites/RajDemo"
4. Force delete SharePoint site collection using PowerShell
Below is the PowerShell SharePoint Command to force delete SharePoint site collection using PowerShell script.
$Site = Get-SPSite https://www.enjoysharepoint.com/sites/RajDem
$SiteContentDB = $site.ContentDatabase
$SiteContentDB.ForceDeleteSite($Site.Id, $false, $false)
5. PowerShell delete all site collections in a web application in SharePoint
Below is the PowerShell SharePoint command which will delete all site collections in a web application in SharePoint 2013/2016/2019.
$WebAppURL="https://www.enjoysharepoint.com/sites/RajDemo"
Get-SPWebApplication $WebAppURL | Get-SPSite -Limit ALL | Remove-SPSite -Confirm:$false
6. Bulk delete site collections with PowerShell
Below the PowerShell script which will delete site collections in bulk in SharePoint.
Get-SPSite "https://www.enjoysharepoint.com/sites/RajDemo" -Limit ALL | Remove-SPSite -Confirm:$false
7. PowerShell Get site information in SharePoint
Below is the PowerShell SharePoint command to get site information in SharePoint 2013/2016.
Get-SPSite 'https://www.enjoysharepoint.com/sites/RajDemo' | Get-SPWeb -Limit All | Select Title
8. PowerShell get all site collections in a SharePoint farm
Below is the PowerShell SharePoint command, which will get all site collections in a SharePoint farm.
Get-SPWebApplication | Get-SPSite -Limit All | Format-Table -Property URL,ContentDatabase
9. Get all subsites from Site Collection using PowerShell
Below is the PowerShell script to get all subsites from SharePoint Site collection using PowerShell.
Get-SPWebApplication https://www.enjoysharepoint.com/sites/RajDemo | Get-SPSite -Limit All | Get-SPWeb -Limit All | Select Title, URL |
Export-CSV C:\SharePoint_Sites_Report.csv -NoTypeInformation
10. Get all subsites of a subsite using PowerShell in SharePoint
Below is the PowerShell SharePoint commands to get all subsites of a subsite using PowerShell in SharePoint 2013/2016/2019.
param ( [Parameter(Mandatory=$true)][ValidateNotNullOrEmpty()] [String]$StartWeb, [Boolean]$IncludeStartWeb = $true )
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
$subsites = ((Get-SPWeb $StartWeb).Site).allwebs | ?{$_.url -like "$StartWeb*"}
foreach($subsite in $subsites) { Write-Host $subsite.url }
11. SharePoint PowerShell backup content database
Below is the PowerShell command to take backup of content database in SharePoint.
Backup-SPFarm -Directory <BackupFolder> -BackupMethod {Full | Differential} -Item <ContentDatabaseName> [-Verbose]
12. SharePoint PowerShell restore a content database
Below is the PowerShell SharePoint command which will restore SharePoint content database in SharePoint 2013/2016.
Get-SPContentDatabase -ConnectAsUnattachedDatabase -DatabaseName <DatabaseName> -DatabaseServer <DatabaseServer>
13. Backup site using PowerShell SharePoint 2013/2016/2019
Below is the PowerShell command to backup site in SharePoint 2013.
Backup-SPSite https://www.enjoysharepoint.com/sites/RajDemo -Path C:\Backup\site_name.bak -UseSqlSnapshot
14. Restore site using PowerShell in SharePoint 2013/2016/2019
Below is the PowerShell command to restore site in SharePoint 2013/2016 using PowerShell.
Restore-SPSite https://www.enjoysharepoint.com/sites/RajDemo -Path C:\Backup\site_name.bak -Force -DatabaseServer SQLBE1 -DatabaseName SQLDB1
15. Get all lists in a SharePoint Site using PowerShell
Below is the PowerShell SharePoint commands to get all lists in a SharePoint site using PowerShell.
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
$Site = Get-SPSite "https://www.enjoysharepoint.com/sites/RajDemo"
# get the all sub sites of site
$SubSites = $Site.AllWebs
$SubSites | ForEach-Object {
$Site = $_
# get all lists from site
$lists = $Site.Lists | Where-Object { $_.BaseType -eq 'GenericList' }
$lists | ForEach-Object {
New-Object -TypeName PSObject -Property @{
ListName = $_.Title
SiteName = $Site.Title
SiteUrl = $Site.Url
}}}
16. Get all libraries in a SharePoint Site using PowerShell
Below is the PowerShell script which will retrieve all libraries in a SharePoint site.
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
$Site = Get-SPSite "https://www.enjoysharepoint.com/sites/RajDemo"
# get the all sub sites of site
$SubSites = $Site.AllWebs
$SubSites | ForEach-Object {
$Site = $_
# get all document Libraries from site
$lists = $Site.Lists | Where-Object { $_.BaseType -eq 'DocumentLibrary' }
$lists | ForEach-Object {
New-Object -TypeName PSObject -Property @{
LibraryName = $_.Title
SiteName = $Site.Title
SiteUrl = $Site.Url
}}}
17. Create a List using PowerShell in SharePoint
Below is the PowerShell script to create a list in SharePoint using PowerShell.
- Create, Update, Delete and Display List items using JavaScript
- Create SharePoint List Definition using Visual Studio (Step by Step Tutorial)
- Create List and respective fields programmatically Office 365 SharePoint 2013
- How to create a list using jsom (JavaScript object model) in SharePoint?
Add-PSSnapin 'Microsoft.SharePoint.PowerShell' -ErrorAction SilentlyContinue
$SPweb = Get-SPWeb -Identity 'https://www.enjoysharepoint.com/sites/RajDemo'
$ListTemplate = $SPweb.ListTemplates['Custom List']
$SPweb.Lists.Add('SharePoint', 'List creation demo using PowerShell' , $ListTemplate)
18. Delete List in SharePoint using PowerShell
Below is the PowerShell command to delete list in SharePoint 2013/2016/2019.
Add-PSSnapin 'Microsoft.SharePoint.PowerShell' -ErrorAction SilentlyContinue
$SPweb = Get-SPWeb -Identity 'https://www.enjoysharepoint.com/sites/RajDemo'
$list = $SPweb.Lists['SharePoint']
$item1 = $list.Items
$item1[0].Delete()
19. PowerShell add item to SharePoint list
Below is the PowerShell command to add item to SharePoint 2013/2016 list.
Add-PSSnapin 'Microsoft.SharePoint.PowerShell' -ErrorAction SilentlyContinue
$SPweb = Get-SPWeb -Identity 'https://www.enjoysharepoint.com/sites/RajDemo'
$list = $SPweb.Lists['SharePoint']
$item1 = $list.Items.Add()
$item1['Title'] = 'Chendrayan'
$item1.update()
20. Get list and libraries having versioning enabled in SharePoint using PowerShell
Below is the PowerShell script which will retrieve lists and libraries having versioning enabled and the list is not hidden in SharePoint using PowerShell.
Get-SPWeb https://www.enjoysharepoint.com/sites/RajDemo |
Select -ExpandProperty Lists |
Where { -not $_.hidden -and
$_.EnableVersioning -eq $true} |
Select ParentWebUrl, title
21. Delete Item in a specific list in SharePoint using PowerShell
Below is the PowerShell SharePoint command to delete items from a SharePoint list.
System.Reflection.Assembly]::LoadWithPartialName(“Microsoft.SharePoint”)
$site = new-object Microsoft.SharePoint.SPSite("https://www.enjoysharepoint.com/sites/RajDemo")
$relweburl = ”/rajtest”
$web = $site.openweb($relweburl)
$list = $web.Lists[“RajList”]
$listItems = $list.Items
$listItemsTotal = $listItems.Count
for ($item=$listItemsTotal-1;$item -ge 0; $item–)
{
Write-Host(“DELETED: ” )
$listItems[$item].Delete()
}
}
22. SharePoint PowerShell bulk delete list items
Below is the PowerShell script to delete list items in bulk in SharePoint.
Add-PSSnapin Microsoft.SharePoint.Powershell -ea SilentlyContinue
$web = get-spweb "https://www.enjoysharepoint.com/sites/RajDemo"
$list = $web.lists["List Title"]
$query = New-Object Microsoft.SharePoint.SPQuery
$query.ViewAttributes = "Scope='Recursive'"
$query.RowLimit = 1000
$query.ViewFields = "<FieldRef Name='ID'/>"
$query.ViewFieldsOnly = $true
do
{
$listItems = $list.GetItems($query)
$query.ListItemCollectionPosition = $listItems.ListItemCollectionPosition
foreach($item in $listItems)
{
Write-Host "Deleting Item - $($item.Id)"
$list.GetItemById($item.Id).delete()
}
}
while ($query.ListItemCollectionPosition -ne $null)
23. Activate features using PowerShell in SharePoint
Below is the PowerShell command to activate feature in SharePoint. You may like the following SharePoint features tutorials:
- Get features (with hidden) using PowerShell in SharePoint 2013/2016
- SharePoint 2016 new features
Enable-SPFeature –Identity Reporting –url https://www.enjoysharepoint.com/sites/RajDemo
24. Deactivate features using PowerShell in SharePoint
Below is the PowerShell command to deactivate features using PowerShell in SharePoint.
Disable-SPFeature –Identity Reporting –url https://www.enjoysharepoint.com/sites/RajDemo
25. Get all features using PowerShell in SharePoint
Below is the PowerShell command to get all the features in SharePoint 2013/2016.
Get-SPFeature –Site https://www.enjoysharepoint.com/sites/RajDemo
26. Add user to a SharePoint group using PowerShell
Below is the PowerShell command to add user to a SharePoint group.
#Get the Web
$web=Get-SPWeb "https://www.enjoysharepoint.com/sites/RajDemo"
#Get the SharePoint Group
$Group= $web.Groups["DHLOwners"]
$userName = "SPADmin\rswain"
#Add User to the site collection
$user = $web.EnsureUser($UserName)
#Add User to the Group
$group.AddUser($user)
27. Remove user from SharePoint group using PowerShell
Below is the PowerShell SharePoint Command to remove users from SharePoint group.
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
Function RemoveUser-FromGroup($SiteURL, $GroupName, $UserAccount)
{
try
{
$ErrorActionPreference = "Stop"
#Get the Web
$web=Get-SPWeb $SiteURL
#Get the User to Remove
$User = Get-SPUser -Identity $UserAccount -Web $web
#Get the Group by its name
$Group = $Web.sitegroups | Where-Object {$_.Name -eq $GroupName}
if($Group -ne $null)
{
#sharepoint powershell delete user from group
$Group.RemoveUser($User)
Write-Host "$($User) Removed from the Group: $($GroupName)"
}
}
catch
{
#Write error message on screen and to a LOG file
write-host $_.Exception.Message
}
finally
{
$ErrorActionPreference = "Continue"
}
}
#Call the function to remove user from SharePoint group
RemoveUser-FromGroup "https://www.enjoysharepoint.com/sites/RajDemo" "DHL Owners" "SPADMIN\rswain"
28. Remove user from all SharePoint groups using PowerShell
Below is the PowerShell command to remove users from all SharePoint groups using PowerShell in SharePoint 2013/2016.
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
Function RemoveUser-FromAllGroups($SiteURL, $UserAccount)
{
#Get the Web
$web=Get-SPWeb $SiteURL
#Get the User to Remove
$User = $Web.EnsureUser($UserAccount)
#Iterate through all Groups
foreach($Group in $Web.Groups)
{
$GroupUser = $Group.Users | where {$_.UserLogin -eq $User.UserLogin}
#Check if user member of the group
if($GroupUser -ne $null)
{
#remove user from sharepoint group using powershell
$Group.RemoveUser($User)
Write-Host "$($User) Removed from the Group: $($Group)"
}
}
}
#Call the function to remove a user from all groups in the site
RemoveUser-FromAllGroups "https://www.enjoysharepoint.com/sites/RajDemo" "SPADMIN\rswain"
29. Create a SharePoint group using PowerShell
Below is the PowerShell command or script to create a SharePoint group using PowerShell in SharePoint 2013/2016.
Add-PSSnapin Microsoft.SharePoint.PowerShell –ErrorAction SilentlyContinue
#Custom Function to Create new SharePoint Group
function Create-SPGroup
{
param ($SiteURL, $GroupName, $PermissionLevel, $GroupDescription)
try
{
#Get the Web
$web = Get-SPWeb -Identity $SiteURL
if($web -ne $null)
{
#Check if Group Exists already
if ($web.SiteGroups[$GroupName] -ne $null)
{
write-Host "Group $GroupName exists Already!" -ForegroundColor Red
}
else
{
#Create SharePoint Group
$Web.SiteGroups.Add($GroupName, $web.Site.Owner, $web.Site.Owner, $GroupDescription)
#Get the newly created group and assign permission to it
$Group = $web.SiteGroups[$groupName]
$roleAssignment = new-object Microsoft.SharePoint.SPRoleAssignment($group)
$roleDefinition = $web.Site.RootWeb.RoleDefinitions[$permissionLevel]
$roleAssignment.RoleDefinitionBindings.Add($roleDefinition)
$web.RoleAssignments.Add($roleAssignment)
$web.Update()
write-Host "Group: $GroupName created successfully!" -ForegroundColor Green
}
$web.Dispose()
}
}
catch [System.Exception]
{
write-host $_.Exception.ToString() -ForegroundColor Red
}
}
#Call the function to create Sharepoint group
Create-SPGroup "https://www.enjoysharepoint.com/sites/RajDemo" "My Powershell Group"
30. Delete a SharePoint group using PowerShell
Below is the PowerShell SharePoint command to delete a SharePoint group using PowerShell in SharePoint 2013/2016. You may like following SharePoint group tutorials:
- Read uses from Active Directory groups add as of SharePoint groups programmatically
- Send Email to SharePoint group using visual studio workflow
- SharePoint Groups or Active Directory (AD) Groups which should we prefer?
Add-PSSnapin “Microsoft.SharePoint.PowerShell”
#Get web
$spWeb = Get-SPWeb "https://www.enjoysharepoint.com/sites/RajDem";
#Your group name
$GroupName="My SharePoint Group"
if($spWeb.SiteGroups[$GroupName] -ne $null)
{
$spWeb.SiteGroups.Remove($GroupName)
$spWeb.Update()
Write-Host “Group Deleted!”
}
else
{
Write-Host “Group doesn’t Exists!”
}
31. Get all SharePoint users using PowerShell in SharePoint 2013/2016
Below is the PowerShell SharePoint command to get all users from SharePoint group using PowerShell in SharePoint 2013/2016.
function GetSPAllSPUsers($SiteCollectionURL,$SPListName)
{
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") > $null
$site = new-object Microsoft.SharePoint.SPSite($SiteCollectionURL)
$web = $site.openweb()
$list = $web.Lists[$SPListName]
$siteCollUsers = $web.SiteUsers
foreach($user in $siteCollUsers)
{
Write-Host " ------------------------------------- "
Write-Host "Site Collection URL:", $SiteCollectionURL
if($list.DoesUserHavePermissions([Microsoft.SharePoint.SPBasePermissions]::ViewListItems,$user) -eq $true)
{
Write-Host "User : ", $user.LoginName
Write-Host "Assigned Permissions : ", $list.GetUserEffectivePermissions($user.LoginName)
}
Write-Host " ------------------------------------- "
}
$web.Dispose()
$site.Dispose()
}
32. Get all groups in SharePoint using PowerShell
Below is the PowerShell command to get all groups in SharePoint using PowerShell.
$web = Get-SPWeb $webUrl;
$groups = $web.AssociatedGroups;
33. Change Site collection URL using PowerShell in SharePoint
Below is the PowerShell SharePoint command to change the site collection URL in SharePoint 2013/2016 using PowerShell. Also, read 3 Different ways to Change Site Collection URL in SharePoint 2013/2016 using PowerShell.
$site = Get-SPSite https://www.enjoysharepoint.com/sites/RajDem
$site.Rename("https://www.enjoysharepoint.com/sites/RajDemo1")
34. Change site collection Title and Description using PowerShell SharePoint 2013/2016
Below is the PowerShell SharePoint command to change the SharePoint site collection title and description.
function Using-Culture (
[System.Globalization.CultureInfo] $culture = (throw "USAGE: Using-Culture -Culture culture -Script {…}"),
[ScriptBlock] $script = (throw "USAGE: Using-Culture -Culture culture -Script {…}"))
{
$OldCulture = [Threading.Thread]::CurrentThread.CurrentCulture
$OldUICulture = [Threading.Thread]::CurrentThread.CurrentUICulture
try {
[Threading.Thread]::CurrentThread.CurrentCulture = $culture
[Threading.Thread]::CurrentThread.CurrentUICulture = $culture
Invoke-Command $script
}
finally {
[Threading.Thread]::CurrentThread.CurrentCulture = $OldCulture
[Threading.Thread]::CurrentThread.CurrentUICulture = $OldUICulture
}
}
$web = Get-SPWeb "https://www.enjoysharepoint.com/sites/RajDem"
$newTitle = "My new Title"
$newDesc = "My new Description"
# de-DE = German - Germany ; en-US = English - United States
Using-Culture de-DE { $web.Title=$newTitle; $web.Description=$newDesc; $web.Update() }
35. SharePoint PowerShell copy list items to another list
The below PowerShell command is to copy list items to another list using PowerShell in SharePoint 2013/2016.
$WebURL = "https://www.enjoysharepoint.com/sites/RajDem"
$SourceListName = "Source SharePoint"
$TargetListName= "Destination SharePoint"
#Get Objects
$web = Get-SPWeb $WebURL
$SourceList = $web.Lists[$SourceListName]
$TargetList = $web.Lists[$TargetListName]
#Get all source items
$SourceColumns = $sourceList.Fields
$SourceItems = $SourceList.GetItems();
#Iterate through each item and add to target list
Foreach($SourceItem in $SourceItems)
{
$TargetItem = $TargetList.AddItem()
Foreach($column in $SourceColumns)
{
if($column.ReadOnlyField -eq $False -and $column.InternalName -ne "Attachments")
{
$TargetItem[$($column.InternalName)] = $sourceItem[$($column.InternalName)];
}
}
$TargetItem.Update();
}
36. Create a folder under a library in SharePoint using PowerShell
Below is the PowerShell SharePoint command to create a folder under a library in SharePoint 2013/2016. Below are also different ways to create a folder in SharePoint:
- SharePoint rest api create folder | SharePoint create folder programmatically using CSOM
$webUrl = "https://www.enjoysharepoint.com/sites/RajDem"
$listName = "My Parent List"
$numberFoldersToCreate = 4000;
$folderNamePrefix = "folder";
# Open web and library
$web = Get-SPWeb $webUrl
$list = $web.Lists[$listName]
# Create desired number of subfolders
for($i=1; $i -le $numberFoldersToCreate; $i++)
{
$folder = $list.AddItem("", [Microsoft.SharePoint.SPFileSystemObjectType]::Folder, "$folderNamePrefix$i")
$folder.Update()
write-host $i
}
#Dispose web
$web.Dispose()
37. Change SharePoint authentication from classic mode to claims based mode using PowerShell
Let us see, how to change SharePoint authentication from classic mode to claims based mode in SharePoint using PowerShell. I will show how to change SharePoint authentication from classic mode to claims based PowerShell.
Recently I migrated the site from SharePoint 2013 to SharePoint 2016 and I faced some problems in authentication type in the targeted SharePoint server.
So after few RND, I got to know the solution to fix this issue. I missed to change the authentication type in targeted server. I executed the below Powershell script to achieve it.
Change SharePoint authentication from classic mode to claims based Power
Below is the PowerShell script to change SharePoint authentication from classic mode to claims mode using PowerShell.
You can write, debug, test the PowerShell script using visual studio code or using windows PowerShell ISE.
$WebAppName = "http://hqRajdev16"
$wa = get-SPWebApplication $WebAppName
$wa.UseClaimsAuthentication = $true
$wa.Update()
$account = "TestAccount\Rajkiran"
$account = (New-SPClaimsPrincipal -identity $account -identitytype 1).ToEncodedString()
$wa = get-SPWebApplication $WebAppName
$zp = $wa.ZonePolicies("Default")
$p = $zp.Add($account,"PSPolicy")
$fc=$wa.PolicyRoles.GetSpecialRole("FullControl")
$p.PolicyRoleBindings.Add($fc)
$wa.Update()
$wa.MigrateUsers($true)
$wa.ProvisionGlobally()
When you execute this command, a confirmation message will appear on the screen. Type Y for confirmation.
After the command executed successfully, check the authentication provider from the SharePoint Central Administration, it will show “claims based authentication”
38. Get Service Applications using PowerShell in SharePoint
Let us see, how to get all service applications using PowerShell in SharePoint 2019/2016/2013.
Service applications have been introduced in SharePoint 2013. Few service applications are: Search service application, Business Data Connectivity Serice, App Management Service, etc.
We can use PowerShell to create, configure and manage these service applications in SharePoint 2013/2016/2019.
We can use PowerShell to get all the available service applications in SharePoint environment. We can use the Windows PowerShell ISE or Visual studio code, to run the below command which will give all the service applications in SharePoint.
Add-PSSnapin Microsoft.SharePoint.PowerShell -EA SilentlyContinue
GET-SPServiceApplication | Format-Table {$_.DisplayName}
Once you run the above command it will display the service application list like below:
$_.DisplayName
————–
Access Services 2010
Secure Store Service
PowerPoint Conversion Service Application
State Service
Workflow Service Application
Project Server Service Application
PerformancePoint Service Application
Visio Graphics Service
Managed Metadata Service
App Management Service
Security Token Service Application
Machine Translation Service
Application Discovery and Load Balancer Service Application
Usage and Health data collection
Subscription Settings Service
Search Administration Web Service for Search Service Application
Word Automation Services
User Profile Service Application
Business Data Connectivity Service
Access Services
Search Service Application
You can see the result it will appear like below:
This is how to get all services applications using PowerShell in SharePoint 2013/2016/2019.
38. How to Change SharePoint master page using PowerShell
Let us see how to change SharePoint master page using PowerShell. Here I will show, how we can set a custom master page as default master page in SharePoint 2013 site.
SharePoint 2013 has two new default master page:
- Seattle.master
- oslo.master
The difference between Seattle.master and oslo.master is that if you use Oslo. master, the top navigation pane is replaced with the left navigation pane, and the sidebar on the left disappears.
Meaning that normally in the left navigation Home, Documents, Recent, Site Contents links usually appear. When you apply Oslo. master these links will appear in the top navigation pane. And there will be no links in the left sidebar.
Here I have developed a custom master page in SharePoint 2013 and I will set that custom master page as the default master page.
Below is the PowerShell command to set master page in SharePoint 2013, which we can run using Windows PowerShell ISE on the SharePoint server.
$web = Get-SPWeb http://win-pfcp2dgt8di/sites/EnjoySharePoint
$web.CustomMasterUrl = “/_catalogs/masterpage/mycustom.master”
$web.MasterUrl = “/_catalogs/masterpage/mycustom.master”
$web.Update()
This is how to set the master page in SharePoint 2013 using PowerShell.
39. Disable list throttling SharePoint 2013 PowerShell
Let us see, how to enable or disable list throttling using PowerShell in SharePoint 2013/2016/2019. Microsoft has set a default threshold limit of 5000 items to the SharePoint list, once your list increased beyond you will get a message like The number of items in this list exceeds the list view threshold.
There are many cases where you want to deal with a huge amount of data in the SharePoint list, whereas you need to bypass the threshold limit of a particular SharePoint list. So to override the default throttling settings. Just execute the below PowerShell to add list items more than the threshold limits.
To overcome the threshold issue the straightforward solution is to increase the threshold limit for the particular list.
Below is the PowerShell command to disable the list throttling for a particular list in SharePoint 2013/2016/2019.
Add-PSSnapin Microsoft.SharePoint.PowerShell
$web = Get-SPWeb http://SiteURL/
$web.AllowUnsafeUpdates = $True
$list = $web.Lists[“YourListName”]
$list.EnableThrottling = $false
$list.Update()
$web.AllowUnsafeUpdates = $False
$web.Update()
$web.Dispose()
40. Enable list throttling SharePoint 2013 PowerShell
Below is the PowerShell command to enable list throttling for a particular list in SharePoint 2013/2016/2019.
Add-PSSnapin Microsoft.SharePoint.PowerShell
$web = Get-SPWeb http://SiteURL/
$web.AllowUnsafeUpdates = $True
$list = $web.Lists[“YourListName”]
$list.EnableThrottling = $true
$list.Update()
$web.AllowUnsafeUpdates = $False
$web.Update()
$web.Dispose()
You may also like the following SharePoint tutorials:
- Page Viewer Web Part in SharePoint
- Excel cannot connect to the SharePoint list
- Download SharePoint Manager
- How to Check SharePoint version installed on the server?
- The workbook cannot be opened error in SharePoint 2013
- Where is Recycle Bin in SharePoint 2013?
- http error 503. the service is unavailable in SharePoint 2013/2016/2010
- How to Change Layout of a Page in SharePoint 2013
These are some PowerShell SharePoint command to work site, list, library, groups, etc. in SharePoint and I will keep adding more examples..
Rajkiran is currently working as a SharePoint Consultant in India . Rajkiran having 7+ years of experience in Microsoft Technologies such as SharePoint 2019/2016/2013/2010, MOSS 2007,WSS 3.0, Migration, Asp.Net, C#.Net, Sql Server, Ajax, jQuery etc.He is C#Corner MVP (2 Times).
[…] is the PowerShell script which can be used to create a list or document library in SharePoint […]
[…] We can create a web application by using a browser from SharePoint 2013 central admin as well as we can create a web application through PowerShell. […]
[…] I will show several options here. We will see how we can enable the developer dashboard using PowerShell, using the object model and using […]
Thank you for the article and information!
I’ve often wondered, from only the client-side, for SP2016 on-prem, is it possible to use PowerShell commands as a Site Collections admin without having access to the SharePoint Servers? That is, remote capability to use PowerShell?
Great list! Do you happen to have something similar to retrieve a list of all 3rd party applications that are installed on each site? [not whats in the app library]