PowerShell - Create multiple SPWebs

PowerShell - Create multiple SPWebs

I often find myself in need of building a structure of SPWebs for demo purposes or for custom migrating scenarios. In order for me to build the structure fast, test it and then tear it down or extend it, I use PowerShell.

Just extend the $url and the $name so they match your desire.


Add-PSSnapin microsoft.sharepoint.powershell
 $pre = "https://intranet/"
 $url = (
 "site",
 "site/subsite",
 )

$name = (
 "Sitename",
 "Subsite name",
 )

for($i=0; $i -le $url.Count; $i++)
 {
 $urlvalue = $url[$i]
 $namevalue = $name[$i]
 New-SPWeb -Url($pre + $urlvalue) -Template CMSPUBLISHING#0 -UseParentTopNav -Name $namevalue -Language 1030
 }