I am able to retrieve the List name of a document library with the following Document Library:


However, I encountered the following error for the following List:


The difference is the additional /Lists/ component in the 2nd URL.

Below is my code snippet, may I know how can I tackle this issue?

$web = Get-SPWeb $baseUrl

$RDlistName ="RecordsDocument"    //success
$FPlistName ="Lists/FilePlan"     //failed
//$FPlistName ="FilePlan"         //failed

$RDlist = $web.Lists[$RDlistName] //success
$FPlist = $web.Lists[$FPlistName] //empty value

Write-host List Name: $RDlist     //success
Write-host List Name: $FPlist     //empty value
  • try with the display name of the "FilePlan" list – Karthik Jaganathan Dec 2 '19 at 5:55

Try to use the PowerShell command below:

$web = Get-SPWeb $baseUrl
$FPlistName ="ListName"
$FPlist = $web.Lists[$FPlistName]
Write-host List Name: $FPlist.Title

Check if it return data. If the issue exists, use the PowerShell command to return all lists and libraries in this web, check if the list exists.

$web = Get-SPWeb $baseUrl
foreach($list in $web.lists){ 
 write-host $list.Title

I think the best way is using url of your list that never change. Your list title can be changed

$webUrl = "http://mySiteUrl"

$listUrl = "/lists/myList"

$web = Get-SPWeb $webUrl -ErrorAction:SilentlyContinue;
if($web -eq $null)
     read-Host "cannot access to $($webUrl) push any key to exit"
     exit 0;
Write-Host "connected to $($webUrl) Title $($web.Title)"

$list = $web.GetList([Microsoft.Sharepoint.Utilities.SPUtility]::ConcatUrls($web.ServerRelativeUrl, $listUrl));

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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