
Connect-SPOService -Url https://KINGdotNET-admin.sharepoint.com -credential [email protected] $host.Runspace.ThreadOptions = "ReuseThread" #Definition of the function that allows to enable a SPO Feature function Enable-SPOFeature { param ($sSiteColUrl,$sUserName,$sPassword,$sFeatureGuid) try { #Adding the Client OM Assemblies Add-Type -Path "C:\Program Files\Common Files\microsoft shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll" Add-Type -Path "C:\Program Files\Common Files\microsoft shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll" #SPO Client Object Model Context $spoCtx = New-Object Microsoft.SharePoint.Client.ClientContext($sSiteColUrl) $spoCredentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($sUsername, $sPassword) $spoCtx.Credentials = $spoCredentials Write-Host "----------------------------------------------------------------------------" -foregroundcolor Green Write-Host "Enabling the Feature with GUID $sFeatureGuid !!" -ForegroundColor Green Write-Host "----------------------------------------------------------------------------" -foregroundcolor Green $guiFeatureGuid = [System.Guid] $sFeatureGuid $spoSite=$spoCtx.Site $spoSite.Features.Add($sFeatureGuid, $true, [Microsoft.SharePoint.Client.FeatureDefinitionScope]::None) $spoCtx.ExecuteQuery() $spoCtx.Dispose() } catch [System.Exception] { write-host -f red $_.Exception.ToString() } } #Required Parameters $sSiteColUrl = "https://KINGdotNET.sharepoint.com/proposalservices" $sUserName = "[email protected]" $sFeatureGuid= "e995e28b-9ba8-4668-9933-cf5c146d7a9f" $sPassword = Read-Host -Prompt "Enter your password: " -AsSecureString $sPassword=convertto-securestring "YourPassword" -asplaintext -force Enable-SPOFeature -sSiteColUrl $sSiteColUrl -sUserName $sUserName -sPassword $sPassword -sFeatureGuid $sFeatureGuidIf you execute the script without error, you should be able to create a sub-site using a custom template.
I hope this save you some time. KINGdotNET
Source: http://www.king.net/sharepoint-online-create-new-subsite-error/
0 Comments