SharePoint Online: Get List By Title, GUID using PowerShell
SharePoint Online: PowerShell to Get List by Title
Here is how to get list by its title.
Get List by ID (GUID) in SharePoint Online:
Here is how to get list by its title.
#Load SharePoint CSOM Assemblies Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll" Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll" #Config Parameters $SiteURL="https://crescenttech.sharepoint.com" $ListName="Documents" #Setup Credentials to connect $Cred= Get-Credential $Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.Username, $Cred.Password) #Setup the context $Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL) $Ctx.Credentials = $Credentials #Get the List $List=$Ctx.Web.Lists.GetByTitle($ListName) $Ctx.load($List) $Ctx.ExecuteQuery() Write-host "Total Number of List Items:"$List.ItemCount
Get List by ID (GUID) in SharePoint Online:
#Load SharePoint CSOM Assemblies Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll" Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll" #Config Parameters $SiteURL="https://crescenttech.sharepoint.com" $ListGUID = [System.Guid]("9a939664-ace4-44af-ad6e-26cefd2e8d32") #Setup Credentials to connect $Cred= Get-Credential $Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.Username, $Cred.Password) #Setup the context $Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL) $Ctx.Credentials = $Credentials #Get List by id $List=$Ctx.Web.Lists.GetById($ListGUID) $Ctx.load($List) $Ctx.ExecuteQuery() Write-host "Total Number of List Items:"$List.ItemCount
SharePoint Online: Get List By Title, GUID using PowerShell
Reviewed by Salaudeen Rajack
on
February 17, 2017
Rating:
No comments:
Please Login and comment to get your questions answered!