The PowerShell Script given below will create a subsite with the blank template and multiple document libraries, using custom template.
In my case, custom template name is Farm Template.
Add-PSSnapin "Microsoft.SharePoint.Powershell".
- #create a subsite using blank Template
-
- $WebAppUrl="https://SharePoint.com/Sites/TEST"
-
- #->SubSite1<-
- $SubSiteTitle1 = "Subsite"
- $SubSite1Url = "Subsite"
- New-SPWeb –url $WebAppUrl"/"$SubSite1Url -name $SubSiteTitle1 -Template "STS#1" –AddToTopNav –UseParentTopNav
-
- #load the custom template to new subsite
-
- $site = Get-SPSite https:
- $web = Get-SpWeb https:
-
- $custTemplate = $site.GetCustomListTemplates($web)
-
- #Verify the custom template name
-
- $custTemplate | select name
-
- write-host "Loading powershell module" -ForegroundColor Red
-
- # specify the source and destination sites
- $sourceWeb = "https://SharePoint.com/Sites/TEST";
- $DestinationWeb = "https://SharePoint.com/Sites/TEST/Subsite";
-
-
- # get the source and destination sites web objects
- $sourceWebObj = Get-SPWeb $sourceWeb;
- $DestinationWebObj = Get-SPWeb $DestinationWeb;
-
- #creating new document libraries using custom template.
-
- $listTemplate = [Microsoft.SharePoint.SPListTemplateType]::"FarmTemplate"
- $DestinationWebObj.Lists.Add("01","My Doc Library",$custTemplate["FarmTemplate"]);
- $DestinationWebObj.Lists.Add("02","My Doc Library",$custTemplate["FarmTemplate"]);
- $DestinationWebObj.Lists.Add("03","My Doc Library",$custTemplate["FarmTemplate"]);
- $DestinationWebObj.Lists.Add("04","My Doc Library",$custTemplate["FarmTemplate"]);
- $DestinationWebObj.Lists.Add("05","My Doc Library",$custTemplate["FarmTemplate"]);
You can add as many document libraries as you want.
I hope this helps.
If you like it please leave a comment.