In case you need to update a bunch of sites that look the same. in my case I have to update on a regular base about 120 sites.
Connect-SPOService –Url 'YOUR ADMIN SITE FULL URL"
# Get all sites
Get-SPOHubSite
# so you get the the hub id you need if not just remove the loop on next section
$hubSiteId= "ID HERE"
$sites = Get-SPOSite -Limit ALL
foreach ($site in $sites)
{
$siteDetailed = Get-SPOSite -Detailed $site.Url
if($siteDetailed.HubSiteId -eq $hubSiteId)
{
$siteUrl = $site.url
$siteUrl
$username = "USER HERE"
$password = "PASS SITE"
$ctx = New-Object Microsoft.SharePoint.Client.ClientContext($siteUrl)
$credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($username, (ConvertTo-SecureString $Password -AsPlainText -Force))
$ctx.Credentials = $credentials
$web = $ctx.Web
$ql = $web.Navigation.QuickLaunch
$ctx.load($ql)
$ctx.ExecuteQuery()
$node = $web.Navigation.QuickLaunch | where { $_.Title -eq "TITLE HERE" }
$node.DeleteObject()
$ctx.ExecuteQuery()
}
}
No comments:
Post a Comment