I'm looking to create multiple document libraries on a list of sites.

I've got most the pieces; I'm just having trouble combining them correctly. Here's the code for making the libraries. If I have 50+ sites(same collection) to make these same libraries on, how should I do that?

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue  
    $siteColl = Get-SPWeb -Identity http://sitename/
$listTemplate = [Microsoft.SharePoint.SPListTemplateType]::DocumentLibrary 


1 Answer 1


You can create multiple list using the the following code by reading setting from xml file. You can specified the template as required

$invocation = (Get-Variable MyInvocation).Value
$directorypath = Split-Path $invocation.MyCommand.Path

[xml]$config = Get-Content $directorypath"\Libraries.xml"

foreach($library in $config.libraries.library){
    $web = Get-SPWeb $library.web
    $template = [Microsoft.SharePoint.SPListTemplateType]::($library.template)
    $web.Lists.Add($library.url,$library.description, $template);


Create an xml file called Libraries.xml and copied the following code:

<?xml version="1.0" encoding="utf-8"?>
        <title>Document Library1</title>
        <description>This is a Control library</description>

        <description>This is a Control library</description>

For more info, you can have a look into the following post: http://selingernetwork.com/blog/?p=53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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