Share via


SharePoint 2013: View GUID via PowerShell

Issue

View from the View drop down on SharePoint list disappears.

Background

We had a user who had an issue with a view loading slow, very slow on a SharePoint list. This view was set as default view for the list. We noticed that there were close to 50 odd webparts on the page that was in closed state. We asked the user to delete them from webpart maintenances page by appending URL with ?contents=1.

 

Problem statement

Once you try to load the list again, it loaded with the new view as lending page, and to our surprise the previous view vanished from the View drop down.

Troubleshooting

It seems that one of the webparts which was deleted from the default view had any link-up with the view so deleting webpart deleted this as well.

However, this was difficult to recreate the view as it was having allotted of customization on the page.

We checked the whole list and there was no view the same name and we are clue less what to do. We were able to open the view by typing its name after the list name; however, that was not acceptable solution for the customer.

Though of editing the view using the GUID  from the URL as form the GUI GUID of lost view is not available.

To get Views from the SharePoint site URL: you can refer to the below references:

http://blogs.msdn.com/b/ronalus/archive/2007/09/08/a-little-guid-picker.aspx

http://blogs.technet.com/b/sharepointcomic/archive/2008/12/09/url-decoder-encoder-guid-converter.aspx

 http://allthingsdotnet.net/960/how-to-find-list-and-view-guids

http://www.surfpointtech.com/2013/10/14/sharepoint-list-id-and-view-id-calculator

However, among these none o f my use as we had lost the edit capability from GUI being view not available in View drops down list.

So here not next reference come up to take some help from Share Master Controller, which I refer as PowerShell …! To get View GUID via Powershell and amend in the List URL to get to Views Edit mode to set it as default view to resolve the problem.

I got a very good reference of script while searching online.

$sourceWebURL = “http://sharepointsite
$sourceListName = “MyList”
$spSourceWeb = Get-SPWeb $sourceWebURL
$spSourceList = $spSourceWeb.Lists[$sourceListName]
$spView = $spSourceList.Views
$spView >C:\a.txt

Open txt file you can see <View Name>

http://microsoftechies.com/2013/06/25/powershell-get-list-views-guid

It was my hard luck to say that problem was not limited here as this PowerShell code is for SharePoint 2010 environment. The issue were experiencing was Customer with 2007 environment.  

We all know MOSS has a limited capabilities when it comes to PowerShell and everything needs to be done by calling SharePoint Object model. Further challenge was to prepare SharePoint 2007 to work with PowerShell-

Read the post on forum to check the limited capabilities of what SharePoint 2007 got with PowerShell: http://social.technet.microsoft.com/Forums/sharepoint/en-US/01ff1eda-ee2e-4723-b375-aa54b19b00b7/how-to-install-sharepoint-powershell-to-moss-2007?forum=sharepointgenerallegacy

A old way of preparing SharePoint 2007 for PowerShell: http://nickgrattan.wordpress.com/2007/09/03/preparing-powershell-for-sharepoint-and-moss-2007/

CodePlex Reference for SharePoint 2007 for PowerShell: https://spps.codeplex.com. Instead following all these great source of information we were clue less. Thanks to our MS PFE  who wrote a PoweShell code for me to get this working.

# load in the SharePoint assemblies
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
# equivalent of Get-SPSite
[string]$url = "http://SharePointPortal/sites/Amar"
$collSite = New-Object Microsoft.SharePoint.SPSite($url)
# get the sub site that we want (need to change the title to whatever site you are trying to get)#
$web = $collSite.AllWebs | where {$_.Title -eq 'subSite1'}
# get the list that we need to work on (need to change the title to whatever list you are trying to get)
$rootWeb = $collSite.RootWeb$list = $rootWeb.Lists | where {$_.Title -eq 'Tasks'}
$viewColl = $list.Views foreach ($view in $viewColl) {write-host $view.ID $view.Title $view.DefaultView }
$collSite.Dispose()

Some more reference to manage SharePoint lib using PowerShell:

Deploy a PowerShell Module with SharePoint Cmdlets: http://blogs.technet.com/b/heyscriptingguy/archive/2010/09/29/deploy-a-powershell-module-with-sharepoint-cmdlets.aspx

Use PowerShell Cmdlets to Manage SharePoint Document Libraries

http://blogs.technet.com/b/heyscriptingguy/archive/2010/09/23/use-powershell-cmdlets-to-manage-sharepoint-document-libraries.aspx