1

When creating a new library using PowerShell the URL of the library is not the same its name. What parameter do I need to specify to set the target URL?

$WebUrl = "http://sharepoint/sites/teams/teama"
$title = "Images"
$description = "Images"
$spweb    = Get-SPWeb -Identity $WebUrl
$listTemplate = [Microsoft.SharePoint.SPListTemplateType]::DocumentLibrary  
$spweb.Lists.Add("$title","$description",$listTemplate) 

This produces: http://sharepoint/sites/teams/teama/_layouts/15/start.aspx#/Images1/
which should be: http://sharepoint/sites/teams/teama/_layouts/15/start.aspx#/Images/

  • 1
    It seems you have already library named Images – Atish Dipongkor - MVP Nov 9 '15 at 5:23
  • Thanks Atish. You are correct, there is a folder named 'images' created for a new subsite. This library does not appear in the site contents view - _layouts/15/start.aspx#/_layouts/15/viewlsts.aspx - so I was creating a folder with a name which already existed. Instead of throwing an error SharePoint was 'helpfully' creating a new library with the same name and different url. Can you turn your comment into an answer so I can mark it as the answer to this for future reference by anyone else who experiences this. – Underverse Nov 9 '15 at 5:42
  • Welcome!. Added as answer – Atish Dipongkor - MVP Nov 9 '15 at 5:54
1

It happens when you have already a library/folder named Images and now you are trying to create a new Library/folder by the same name. Sometimes it can not be found in site content view so try to find it by PowerShell or SharePoint Designer.

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.