Build-PorteoSite.ps1
<# .Synopsis Build-PorteoSite -TenantUrl http://site-admin.sharepoint.com -Credentials (Get-Credential) ` -SiteName "Site1" -Title "The Site" -Type "TeamSite" -Owner "name@site.onmicrosoft.com" ` -SrcConnection $srcConnection .Description This cmdlet builds a "Porteo" site, meaning that it specifies and applies a number of SiteDesigns once the site is created. If the site already exists, nothing is done. .Parameter TenantUrl This parameter holds the tenant adminstrative site url. Ex. site-admin.sharepoint.com .Parameter Credentials This parameter holds the credentials for the tenant adminstrator. .Parameter SiteName This parameter holds the name of the site to be created .Parameter Title This parameter holds the title for the site to be created. .Parameter Type This paramter holds the type of site to be created, TeamSite or CommunicationSite. .Parameter Owner This paramter holds the owner of the new site,email address; .Parameter SrcConnection This paramter holds the source to copy the template from. If not specified, no template is copied. #> function Build-PorteoSite { param( $tenantUrl, $credentials, $siteName, $title, $type = "TeamSite", $owner, $srcConnection ) $connection = Connect-PnPOnline -Url $tenantUrl -Credentials $credentials -ReturnConnection $baseUrl = $tenantUrl.Replace("-admin", "") $siteurl = "$baseUrl/sites/$siteName" $site = Get-PnPTenantSite -Url $siteUrl -ErrorAction SilentlyContinue if (-not $site) { $site = Add-SSPSite -Owner $owner -Url $siteUrl -Title $title -SiteName $siteName -Type $type -Connection $connection $siteUrl = $site Write-Host $siteUrl $destConn = Connect-PnPOnline -Url $siteUrl -Credentials $credentials -ReturnConnection $ignore = Set-PnpSite -NoScriptSite $false -Connection $destConn $ignore = Add-PorteoSiteDesigns -Type $type -Connection $connection if ($srcConnection) { $ignore = Copy-SSPSite -SrcConnection $srcConnection -DestConnection $destConn -Handlers $handlers } else { $ignore = New-PnPList -Title "Site Assets" -Template DocumentLibrary -OnQuickLaunch -Connection $destConn $ignore = Invoke-SSPSiteDesigns -SiteDesigns ("DefaultDesign", "AddJournal", "AddLinks", "AddRequests", "AddSiteLists") -Connection $destConn } return $siteUrl } else { Write-Host "Site $siteUrl Exists" return $siteUrl } } $handlers = @( "AuditSettings", "ComposedLook", "CustomActions", "ExtensibilityProviders", # "Features", "Fields", "Files", "Lists", "Pages", "Publishing", "RegionalSettings", "SearchSettings", "SitePolicy", "SupportedUILanguages", "TermGroups", "Workflows", "SiteSecurity", # "ContentTypes", "PropertyBagEntries", "PageContents", "WebSettings", "Navigation", # This seems to duplicate the naviagion sidebar. "ImageRenditions", # "ApplicationLifecycleManagement", # "Tenant", "WebApiPermissions", "SiteHeader", "SiteFooter", "Theme", "SiteSettings", "SyntexModels" ) |