0

I want to get all the list URL from SharePoint 2013 using PowerShell CSOM.

Some one could suggest on this?

2 Answers 2

1

Below is my demo code for your reference:

Add-Type -Path "C:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
$loginname="Contoso\administrator"
$pwd="password"
$siteUrl="http://sp13/sites/michael"
$Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($siteUrl)
$Ctx.Credentials = New-Object System.Net.NetworkCredential($loginname, $pwd)
$lists=$Ctx.Web.Lists
$Ctx.load($lists)
$Ctx.ExecuteQuery()
foreach($list in $lists){
$Ctx.Load($list.RootFolder)  
$Ctx.ExecuteQuery()
$listurl="http://sp13"+$list.RootFolder.ServerRelativeUrl
write-host $listurl 
}
2
  • Thank you... it is working... may i know how to add the domain name like ("sp13") in the list URL
    – Liz
    Jul 28, 2020 at 9:48
  • 1
    Updated in my answer. Jul 28, 2020 at 10:01
0

Check below code:

param
(
[string] $URL,
[boolean] $WriteToFile = $true
)
 
#Get all lists in farm
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
 
#Counter variables
$webcount = 0
$listcount = 0
 
if($WriteToFile -eq $true)
{
    $outputPath = Read-Host "Outputpath (e.g. C:directoryfilename.txt)"
}
if(!$URL)
{
    #Grab all webs
    $webs = (Get-SPSite -limit all | Get-SPWeb -Limit all -ErrorAction SilentlyContinue)
}
else
{
    $webs = Get-SPWeb $URL
}
if($webs.count -ge 1 -OR $webs.count -eq $null)
{
    foreach($web in $webs)
    {
        #Grab all lists in the current web
        $lists = $web.Lists
        Write-Host "Website"$web.url -ForegroundColor Green
        if($WriteToFile -eq $true){Add-Content -Path $outputPath -Value "Website $($web.url)"}
        
        foreach($list in $lists)
        {
            $listcount +=1
            Write-Host " – "$list.Title
            if($WriteToFile -eq $true){Add-Content -Path $outputPath -Value " – $($list.Title)"}
        }
        $webcount +=1
        $web.Dispose()
    }
    #Show total counter for checked webs & lists
    Write-Host "Amount of webs checked:" $webcount
    Write-Host "Amount of lists:" $listcount
}
else
{
    Write-Host "No webs retrieved, please check your permissions" -ForegroundColor Red -BackgroundColor Black
}

Source: Get SharePoint lists by using PowerShell

With some little modifications in above code you can get all the required list details.

Additional resources:

  1. Get all lists in a Sharepoint Site using Powershell
  2. Extract all list names from sharepoint site to csv
  3. Get All Lists and Libraries using PowerShell

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.