Saturday, November 26, 2016

SharePoint Online: 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



You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.
*Sponsored


Check out these SharePoint products:

No comments :

Post a Comment

Please Login and comment to get your questions answered!


You might also like:

Related Posts Plugin for WordPress, Blogger...