Hello,
I create subsites through powershell with a script. This is working but in the newly created subsites the global navigation is not working. in the settings of the subsites 'Display the same navigation items as the parent site' is selected.
If I select another option, save and then select 'Display the same navigation items as the parent site' again it is working.
So seems like some parameter is not set when creating subsites through powershell. anyone an idea on how to set global navigation with powershell?
the script I use:
#Add references to SharePoint client assemblies and authenticate to Office 365 siteAdd-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.Publishing.dll"
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
$Username = Read-Host -Prompt "Please enter your username"
$Password = Read-Host -Prompt "Please enter your password" -AsSecureString
$SiteC = "https://xxxx.sharepoint.com/sites/xxx/xxxxx/"
$Context = New-Object Microsoft.SharePoint.Client.ClientContext($SiteC)
$Creds = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username,$Password)
$Context.Credentials = $Creds
$csvLocation = “D:\sites.csv”
$csv = Import-Csv $csvLocation
ForEach ($site in $csv) {
$site = $($site.name)
#Create SubSite
$WCI = New-Object Microsoft.SharePoint.Client.WebCreationInformation
$WCI.WebTemplate = "{CD28D656-E909-4DF9-B9B3-641E2438E7BE}#testdef1"
$WCI.Description = $site
$WCI.Title = $site
$WCI.Url = $site
$WCI.Language = "1033"
$WCI.L
$SubWeb = $Context.Web.Webs.Add($WCI)
$Context.ExecuteQuery()
}