0

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

http://test.com/RecordsDocument/

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

http://test.com/Lists/FilePlan

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?

$baseUrl="http://test.com/"
$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
1
  • try with the display name of the "FilePlan" list – Karthik Jaganathan Dec 2 '19 at 5:55
0

Try to use the PowerShell command below:

$baseUrl="http://spsite/"
$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.

$baseUrl="http://spsite/"
$web = Get-SPWeb $baseUrl
foreach($list in $web.lists){ 
 write-host $list.Title
}
0
0

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.