I want to create libraries in SharePoint 2010 using PowerShell. So far, so good.

I'm using this chunk of code to create the library (actually list, but that doesn't matter)

    $listTemplate = $currentWeb.ListTemplates | ? {$_.name -eq $webTemplate }
    $newListId = $currentWeb.Lists.Add($line.Url, $line.Description, $listTemplate)
    $newList = $currentWeb.Lists[$newListId]
    $newList.Title = $line.Library
    $newList.OnQuickLaunch = $addToQuickLaunch

But for some strange reason the (display) title of my library doesn't get set to whatever is in $line.Library.

Any hints?

  • What are the values of the $line properties and the $webTemplate?
    – Matthias
    Feb 22 '12 at 16:42
  • $webTemplate = "Document Library" $line.Url = "processes"; $line.Description = ""; $line.Library = "Process Documenation";
    – nyn3x
    Feb 23 '12 at 14:54
  • What kind of object is $line? Mar 30 '12 at 9:39

Is your site in English or is your site in some other language, maybe German. If your site is NOT english, you CAN't update list's title once you've created it unless you manipulate thread's UI culture to match your site's language.

The following blog posts could be helpful in the scenario of not having an english site:




Use a 'Start-SPAssignment/Stop-SPAssignment' pair around your code block. More on Start_SPAssignment here.

  • I do have those at the beginning and the end of the script. Im using Start-SPAssignment -Global.
    – nyn3x
    Feb 23 '12 at 14:52
  • I don't see that in your code. Sep 12 '13 at 13:52
  • I stripped that out - but it's there anyway.
    – nyn3x
    Nov 18 '13 at 13:41
  • then the vote on my post above needs to be corrected? Nov 18 '13 at 14:04
  • @nyn3x How can the one answering your question know what you have left out on your question? Please update your question to give those who take the time answering a chance to make reasonable judgment of what is and what is not present.
    – Benny Skogberg
    Nov 18 '13 at 20:05

I'd suggest to check out the following site, as they are doing something similar. It looks like from what I'm saying it may be determinate on what your object is -- in this case -- they had it seperated out as a string. Have you tried to check what those output as you were debugging?

See below, from site,

function New-SPList {
    Use New-SPList to create a new SharePoint List or Library.
    This advanced PowerShell function uses the Add method of a SPWeb object to create new lists and libraries in a SharePoint Web
    specified in the -Web parameter.
    C:\PS>New-SPList -Web http://intranet -ListTitle "My Documents" -ListUrl "MyDocuments" -Description "This is my library" -Template "Document Library"
    This example creates a standard Document Library in the http://intranet site.
    C:\PS>New-SPList -Web http://intranet -ListTitle "My Announcements" -ListUrl "MyAnnouncements" -Description "These are company-wide announcements." -Template "Announcements"
    This example creates an Announcements list in the http://intranet site.
    You must use the 'friendly' name for the type of list or library.  To retrieve the available Library Templates, use Get-SPListTemplates.
Start-SPAssignment -Global
$SPWeb = Get-SPWeb -Identity $Web
$listTemplate = $SPWeb.ListTemplates[$Template]
$list = $SPWeb.Lists[$ListUrl]
$list.Title = $ListTitle
Stop-SPAssignment -Global
  • But isn't that the same code that I originally posted? Does your (display) title get set using this code?
    – nyn3x
    Nov 19 '12 at 12:54

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.