Delete List View using PowerShell in SharePoint 2013 and Set List View as Default view using PowerShell SharePoint 2013

InfoPath alternatives for form designing SharePoint

In this post we will discuss how we can delete list view using PowerShell in SharePoint 2013. Here in this case I have Test list which has a Test view, I want to delete that through PowerShell.

You can also check:
– SharePoint 2013 Change Page Layout using PowerShell

– Enable or Disable List Throttling using PowerShell in SharePoint 2013

– SharePoint Server 2016 Installation Step by Step

Below is the PowerShell command to delete a list view using PowerShell:

Add-PSSnapin “Microsoft.SharePoint.PowerShell”

$web = Get-SPWeb “http://win-pfcp2dgt8di/sites/EnjoySharePoint/”

$list = $web.GetList(“http://win-pfcp2dgt8di/sites/EnjoySharePoint/Lists/MyTestList1/”)

$myview = $list.Views[“MyTestView”]

$list.Views.Delete($myview.id)

$web.Dispose()

Set List View as Default view using PowerShell SharePoint 2013

We can also set a view as defult view by using PowerShell. Here I have a view name as “MyTestDefaultView” and below is the PowerShell command to set it as default view:

Add-PSSnapin “Microsoft.SharePoint.PowerShell”

$web = Get-SPWeb “http://win-pfcp2dgt8di/sites/EnjoySharePoint/”

$list = $web.GetList(“http://win-pfcp2dgt8di/sites/EnjoySharePoint/Lists/MyTestList1/”)

$view = $list.Views[“MyTestDefaultView”]

$view.DefaultView = $true

$view.Update()

Hope this will be helpful.

Similar SharePoint 2013 Tutorials

About Bijay Kumar

I am Bijay from Odisha, India. Currently working in my own venture TSInfo Technologies in Bangalore, India. I am Microsoft Office Servers and Services (SharePoint) MVP (5 times). I works in SharePoint 2016/2013/2010, SharePoint Online Office 365 etc. Check out My MVP Profile.. I also run popular SharePoint web site SharePointSky.com

View all posts by Bijay Kumar →

Leave a Reply