After created site collection in PowerShell with this command:
$SiteCollection = New-SPSite -Url $WebAPP.Url -OwnerAlias $SiteColl_Owner -Language 1033 -Template $SiteColl_Template -Name $SiteColl_Name
I want to use SPSite object without Get-SPSite
$spListCollection = $SiteCollection.Lists
foreach($List in $SiteCollLists.List)
{
$ListTemplate = $SiteCollection.ListTemplates[$List.Template]
$spListCollection.Add($List.Name, $List.Name, $ListTemplate)
}
Error is:
Cannot index into a null array. At C:\Users\mmma\Desktop\CreatePortal\TestCreateInfra.ps1:69 char:8 + $ListTemplate = $SiteCollection.ListTemplates[$List.Template] + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [], RuntimeException + FullyQualifiedErrorId : NullArray