This SharePoint PowerShell tutorial explains, how to get a SharePoint list or document library GUIDs using PowerShell in SharePoint. The code will work to get SharePoint list GUID using PowerShell in SharePoint 2013/2016. Also, we will see how to Get SharePoint list created date using PowerShell.
We will discuss how to GUID of a SharePoint 2013 list using browser and how to retrieve list name from guid using CSOM (.Net managed object model code) in SharePoint Online.
If you want to get the GUID of a SharePoint list you can easily get it from the browser or also you can get it by using a PowerShell command.
To get the GUID of a particular SharePoint list, Simply open the SharePoint list settings page using browser and then you will see something like below in the browser.
?List=%7BB13CC473-6187-4478-A0DD-853E83AA6F9D%7D
Here whatever presented after %7B and before %7D is your list GUID. In this particular case, the GUID of the SharePoint list will be: B13CC473-6187-4478-A0DD-853E83AA6F9D
Get SharePoint list guid PowerShell
Below is the PowerShell command which will give you the Guids of all SharePoint list and library of the site collection.
Add-PSSnapin "Microsoft.SharePoint.PowerShell"
$site = Get-SPSite http://win-pfcp2dgt8di/sites/EnjoySharePoint/
$web = $site.RootWeb
$lists = $web.lists
$lists | Format-Table title,id -AutoSize
It will look like below:
If you want to find out between generic list and document library then you can put the below command.
Add-PSSnapin "Microsoft.SharePoint.PowerShell"
$site = Get-SPSite http://win-pfcp2dgt8di/sites/EnjoySharePoint/
$web = $site.RootWeb
$lists = $web.lists | Where-Object { $_.BaseType -Eq "GenericList" }
$lists | Format-Table title,id -AutoSize
$libraries = $web.lists | Where-Object { $_.BaseType -Eq "DocumentLibrary" }
$libraries | Format-Table title,id -AutoSize
Read Cannot contact web site or the web site does not support sharepoint online credentials
Get List Name from GUID using PowerShell in SharePoint 2013/2016
Now, we will see how to get a list name from GUID using PowerShell in SharePoint 2013/2016.
Sometimes, you may need to retrieve the List name from the list GUID, PowerShell is the best option for the same.
Recently we got one error in ULS Logs, which display the GUID of the SharePoint list and we use PowerShell to get more about the list.
PowerShell Command to Get SharePoint List Name from GUID
Below is the PowerShell command which will return the List Name, Web URL and Root folder. You can run the PowerShell cmdlets in Windows PowerShell ISE.
Add-PSSnapin "Microsoft.SharePoint.PowerShell"
Get-SPSite http://win-pfcp2dgt8di/sites/EnjoySharePoint/ | Get-SPWeb -Limit ALL | %{$_.Lists} |?{$_.ID –eq "B13CC473-6187-4478-A0DD-853E83AA6F9D"} |ft Title, ParentWebURL, RootFolder
Now, you can see, the PowerShell cmdlets return information about the SharePoint list.
How to get GUID of a SharePoint 2013/2016/Online list
Now, we will see how to get GUID of a SharePoint list using a browser. It will work for SharePoint 2013/2016 or SharePoint Online.
Below is the step to get the SharePoint list ID:
Open the SharePoint list using the browser, then go to the list settings.
Now copy the URL from the browser and put it somewhere in the notepad.
http://win-pfcp2dgt8di/sites/EnjoySharePoint/_layouts/15/listedit.aspx?List=%7B58A98D82-3F9A-4FB6-8CA4-7DB31E233EB2%7D
Now notice whatever present after List= %7B58A98D82-3F9A-4FB6-8CA4-7DB31E233EB2%7D
That is the list ID but we need to format it like below:
- Change “%7B” to “{“
- Change all “%2D” to “-“
- Change “%7D” to “}”
Now the ID should look like this: {58A98D82-3F9A-4FB6-8CA4-7DB31E233EB2}
This is your SharePoint list ID.
Get SharePoint list created date using PowerShell
Now, ler us see how to get the SharePoint list created date using PowerShell. The same PowerShell code, we can use to get list created date using PowerShell in SharePoint 2013/2016.
There is not out of box direct way to get the list created date in SharePoint 2013/2016/Online. But there is a way to get the list created to date using PowerShell.
Get SharePoint list created date using PowerShell
In this example I have a SharePoint site in which I have a SharePoint list name Testing, I want to retrieve the created date of the list using PowerShell.
Add-PSSnapin Microsoft.Sharepoint.Powershell
$web = Get-SPWeb “http://win-pfcp2dgt8di/sites/EnjoySharePoint/”
$list = $web.lists[“Testing”]
$listCreatedDateTime = $list.Created
$web.Dispose()
$web = $null
Write-Host $listCreatedDateTime
The PowerShell command looks like below:
Retrieve list name from guid using CSOM in SharePoint Online
Now, we will discuss how to get the list name from list Guid by using .net managed object model (csom) code in SharePoint online.
Here we will do everything using console application and we will connect to SharePoint online site. Here we will pass a Guid of a list and it will return the name of the list in SharePoint Online.
To work with .Net client object model we need below dlls:
- Microsoft.SharePoint.Client.dll
- Microsoft.SharePoint.Client.ClientRuntime.dll
We can add these dlls from Nuget package manager.
Below is the method which will take the SharePoint site URL and Guid of the list. Here GetById method will return the list and then we can retrieve the list title property from the Title property.
public static string GetListNameFromGUID(string URL, string GUID)
{
Guid guid = new Guid(GUID);
string listName = string.Empty;
ClientContext context = new ClientContext(URL);
context.AuthenticationMode = ClientAuthenticationMode.Default;
context.Credentials = new SharePointOnlineCredentials(GetSPOAccountName(), GetSPOSecureStringPassword());
var web = context.Web;
context.Load(web);
List lst = context.Web.Lists.GetById(guid);
context.Load(lst,l=>l.Title);
context.ExecuteQuery();
return lst.Title;
}
private static SecureString GetSPOSecureStringPassword()
{
try
{
var secureString = new SecureString();
foreach (char c in ConfigurationManager.AppSettings[“SPOPassword”])
{
secureString.AppendChar(c);
}
return secureString;
}
catch
{
throw;
}
}
private static string GetSPOAccountName()
{
try
{
return ConfigurationManager.AppSettings[“SPOAccount”];
}
catch
{
throw;
}
}
We can call the method like below:
string listName = GetListNameFromGUID("https://<tenantname>.sharepoint.com/sites/Bhawana/", "C6D7A7EB-09C0-4E45-B4D8-03C523FEE16D");
Once you run the above code, you can see the result, it will display the list name based on Guid.
You may like following PowerShell SharePoint tutorials:
- Get SharePoint document library size using PowerShell
- Extend web application in SharePoint 2013 using PowerShell
- PowerShell out gridview in SharePoint 2013/2016
- Get all users and groups in SharePoint 2013/2016 using PowerShell
- Working with file modification time and date using PowerShell
- Export user permission in SharePoint 2013/2016 using PowerShell
- Get Content DataBase Size Using PowerShell in SharePoint 2013
- SharePoint PowerShell Script Examples
- Get Service Applications using PowerShell in SharePoint 2013/2016
- Connect to SharePoint Online Site using PowerShell
- The file is not digitally signed PowerShell script
This SharePoint tutorial, we discussed how to get SharePoint list Guids using PowerShell in SharePoint 2013/2016.
- sharepoint powershell get list
- powershell get sharepoint list
- powershell sharepoint list
- get sharepoint list powershell
Bhawana Rathore is a Microsoft MVP (3 times in Office Apps & Services) and a passionate SharePoint Consultant, having around 10 years of IT experience in the industry, as well as in .Net technologies. She likes to share her technical expertise in EnjoySharePoint.com and SPGuides.com