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
    $newList.Update()

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

Any hints?

link|improve this question

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

1 Answer

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

link|improve this answer
I do have those at the beginning and the end of the script. Im using Start-SPAssignment -Global. – nyn3x Feb 23 at 14:52
feedback

Your Answer

 
or
required, but never shown

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