kwizcom banner advertisement

SharePoint Online: How to a Get List in PowerShell?

SharePoint Online: Get List from PowerShell
Here is the PowerShell to Get SharePoint Online List
Import-Module Microsoft.Online.SharePoint.Powershell -DisableNameChecking

#Config Variables for Site URL, List Name
$SiteURL= "https://crescent.sharepoint.com/sites/sales/"
$ListName="Sales Contacts"
 
#Setup Credentials to connect
$Cred = Get-Credential
$Cred = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.UserName,$Cred.Password)
 
Try {
    #Setup the context
    $Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
    $Ctx.Credentials = $Cred
 
    #powershell sharepoint online get list
    $List = $Ctx.Web.Lists.GetByTitle($ListName)
    $Ctx.Load($List)
    $Ctx.ExecuteQuery()

    Write-host "Total Number of Items in the List:"$List.ItemCount
}
 Catch [Exception] {
      Write-host $_.Exception.Message -f Red
} 
This script gets the given list and number of items from the list.

Related Post: SharePoint Online PowerShell to Get All Lists
SharePoint Online: How to a Get List in PowerShell? SharePoint Online: How to a Get List in PowerShell? Reviewed by Salaudeen Rajack on November 26, 2016 Rating: 5

No comments:

Please Login and comment to get your questions answered!

Powered by Blogger.