I am trying to create a document library from a template. The template name has spaces in it through.
#Add the SharePoint snapin
write-host "Loading powershell module" -ForegroundColor Cyan
Add-PSSnapin Microsoft.SharePoint.Powershell -ea SilentlyContinue
# specify the source and destination sites
$sourceWeb = "http://mysite";
$DestinationWeb = "http://mysite/Search";
# get the source and destination sites web objects
$sourceWebObj = Get-SPWeb $sourceWeb;
$DestinationWebObj = Get-SPWeb $DestinationWeb;
$listTemplate = [Microsoft.SharePoint.SPListTemplateType]::"My Enterprise Documents"
$DestinationWebObj.Lists.Add("Documents_Archieve","My Doc Library",$listTemplate);
The error:
Exception calling "Add" with "3" argument(s): "Value cannot be null.
Parameter name: Invalid argument 'template' to SPListCollection.Add() method. Please pass an argument of the appropriate type."
At C:\script\archive3.ps1:32 char:29
+ $DestinationWebObj.Lists.Add <<<< ("Documents_Archieve","My Doc Library",$listTemplate);
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodException
Does anyone know what's wrong?
Thanks