What you will find here

If you are one of those multi hat kind of person you might want to take a look here.
Some of the sections here will cover: SharePoint, SQL, Server, VB Script, Batch files, PCI Compliance

Icon

Icon

Wednesday, March 6, 2019

Delete Items from quick Navigation bar SharePoint Online - PowerShell

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