magritton
11/24/2017 - 10:51 PM

Global Navigation Hide

This Powershell snippet hides or shows global navigation items in a SharePoint site.

#$publishingWeb.Navigation.IncludeInNavigation($false,$webSub.ID);#this shows the subsite in the Current Navigation Section
#$publishingWeb.Navigation.ExcludeFromNavigation($false,$webSub.ID);#this hides the subsite in the Current Navigation Section

#$publishingWeb.Navigation.IncludeInNavigation($true,$webSub.ID);#this shows the subsite in the Global Navigation Section
#$publishingWeb.Navigation.ExcludeFromNavigation($true,$webSub.ID);#this hides the subsite in the Global Navigation Section

#$publishingWeb.Navigation.ExcludeFromNavigation #shows the function parameters
#****************************************************************************************************************************

function Remove-GlobalLink
{
	Param ([string] $nodeName)

	$web = Get-SPWeb https://xxxx/399/964
	$publishingWeb = [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($web) 

	$nodes = $publishingWeb.Navigation.GlobalNavigationNodes
	$linkNode = $nodes | where { $_.Title -eq $nodeName }
	$linkNode.Delete()

	$publishingWeb.Update() 
	$web.Update()
	$web.Close()  
	$web.Dispose()

	write-host "Web $web"
	write-host "Link removed: $nodeName" -backgroundcolor "blue"
}

function Hide-GlobalSubsite
{
	Param ([string] $subwebUrl)

	$web = Get-SPWeb https://xxxx/399/964
	write-host "Web $web"

	$webSub = Get-SPWeb $subwebUrl
	write-host "SubWeb $webSub"
	write-host "SubWeb ID " + $webSub.ID

	#https://xxxx/399/964/sail

	$publishingWeb = [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($web) 

	$publishingWeb.Navigation.ExcludeFromNavigation($true,$webSub.ID);#this shows the subsite in the Global Navigation Section

	$publishingWeb.Update() 
	$web.Update()
	$web.Close()  
	$web.Dispose()
	write-host "Subsite Excluded from Global Navigation"
}

function Unhide-GlobalSubsite
{
	Param ([string] $subwebUrl)

	$web = Get-SPWeb https://xxxx/399/964
	write-host "Web $web"

	$webSub = Get-SPWeb $subwebUrl
	write-host "SubWeb $webSub"
	write-host "SubWeb ID $webSub.ID"
	
	#https://xxxx/399/964/sail

	$publishingWeb = [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($web) 

	$publishingWeb.Navigation.IncludeInNavigation($true,$webSub.ID);#this shows the subsite in the Global Navigation Section
	
	$publishingWeb.Update() 
	$web.Update()
	$web.Close()  
	$web.Dispose()
}

############Current Navigation Section - e.g. the Quick Launch###########################################

function Unhide-CurrentSubsite
{
	Param ([string] $subwebUrl)

	$web = Get-SPWeb https://xxxx/399/964
	write-host "Web $web"

	$webSub = Get-SPWeb $subwebUrl
	write-host "SubWeb $webSub"
	write-host "SubWeb ID " + $webSub.ID

	#https://xxxx/399/964/sail

	$publishingWeb = [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($web) 

	$publishingWeb.Navigation.IncludeInNavigation($false,$webSub.ID);#this shows the subsite in the Current Navigation Section

	$publishingWeb.Update() 
	$web.Update()
	$web.Close()  
	$web.Dispose()
	write-host "Subsite Included in Current Navigation"
}

function Hide-CurrentSubsite
{
	Param ([string] $subwebUrl)

	$web = Get-SPWeb https://xxxx/399/964
	write-host "Web $web"

	$webSub = Get-SPWeb $subwebUrl
	write-host "SubWeb $webSub"
	$subID = $webSub.ID
	write-host "SubWeb ID: $subID" 

	#https://xxxx/399/964/sail

	$publishingWeb = [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($web) 

	$publishingWeb.Navigation.ExcludeFromNavigation($false,$webSub.ID);#this shows the subsite in the Current Navigation Section

	$publishingWeb.Update() 
	$web.Update()
	$web.Close()  
	$web.Dispose()
	write-host "Subsite Excluded from Current Navigation"
}

function Remove-CurrentLinkChild
{
	Param ([string] $linkName, [bool] $displayOnly)
	
	$removed = ""
	$web = Get-SPWeb https://xxxx/399/964
	$publishingWeb = [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($web)
	$nodes = $publishingWeb.Navigation.CurrentNavigationNodes
	$nodes | ForEach{
		$_.Children | ForEach{
				if($_.Title -eq $linkName)
				{
					if($displayOnly)
					{
						$_
					
					}
					else
					{
						$_.Delete()
						$publishingWeb.Update() 
						$web.Update()
						$web.Close()  
						$web.Dispose()
						$removed = $_.Title
						write-host "Web $web"
						write-host "Removed: $removed" -backgroundcolor "blue"
						break
					}
				}
				}#end second for each
	}#end first for each
	

	$publishingWeb.Update() 
	$web.Update()
	$web.Close()  
	$web.Dispose()

	write-host "Web $web"
	write-host "Removed: $removed" -backgroundcolor "blue"
}

function Remove-CurrentLink
{
	Param ([string] $linkName, [string] $displayOnly)

	$web = Get-SPWeb https://xxxx/399/964
	$publishingWeb = [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($web)
	$nodes = $publishingWeb.Navigation.CurrentNavigationNodes
	for($i=$nodes.Count-1;$i -ge 0;$i--)
	{
		if($nodes[$i].Title -eq $linkName)
		{
			$nodes[$i]
			if($displayOnly -eq "No")
			{
				$nodes[$i].Delete()
				write-host "$linkName Deleted"
			}
		}
	}

$publishingWeb.Update() 
$web.Update()
$web.Close()  
$web.Dispose()

}

function Add-CurrentLink
{
	Param ([string] $linkName, [string] $linkURL)

	$CreateSPNavigationNode = [Microsoft.SharePoint.Publishing.Navigation.SPNavigationSiteMapNode]::CreateSPNavigationNode

	$web = Get-SPWeb https://xxxx/399/964
	$publishingWeb = [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($web)
	$nodes = $publishingWeb.Navigation.CurrentNavigationNodes

	$headingNode = $CreateSPNavigationNode.Invoke($linkName, $linkURL, [Microsoft.SharePoint.Publishing.NodeTypes]::Heading, $nodes)

	write-host "Web $web"
	write-host "Added link to the current navigation: $linkName" -backgroundcolor "blue"
}

function Move-CurrentLinkBelowLink
{
	Param ([string] $Mover, [string] $Under)
	
	$web = Get-SPWeb https://xxxx/399/964
	$publishingWeb = [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($web)
	$nodes = $publishingWeb.Navigation.CurrentNavigationNodes

	$nodes
	$qlNewPreviousSibling = $nodes | where { $_.Title -eq $Under }
	$qlNewPreviousSibling
}

function test
{
	$web = Get-SPWeb https://xxxx/399/964
	$publishingWeb = [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($web)
	$nodes = $publishingWeb.Navigation.CurrentNavigationNodes

	$nodes
}

#Unhide-GlobalSubsite -subwebUrl https://xxxx/399/964/Sail

#Hide-GlobalSubsite -subwebUrl https://xxxx/399/964/sail
#Hide-GlobalSubsite -subwebUrl https://xxxx/399/964/CPF

#Unhide-CurrentSubsite -subwebUrl https://xxxx/399/964/sail
#Unhide-CurrentSubsite -subwebUrl https://xxxx/399/964/CPF

#Hide-CurrentSubsite -subwebUrl https://xxxx/399/964/sw

#Remove-CurrentLink -linkName "B851 Relayout Project" -displayOnly "No"
#Remove-CurrentLinkChild -linkName "Misc. Shared Documents" -displayOnly $false
#Add-CurrentLink -linkName "B851 Relayout Project" -linkURL https://xxxx/399/964/SitePages/B851RelayoutProject.aspx
#Move-CurrentLinkBelowLink -Mover "B851 Relayout Project" -Under "Shipwrights"
#Remove-GlobalLink -nodeName "B851 Relayout Project"

test
function Remove-GlobalLink
{
#https://xxx/964/cpf
$web = Get-SPWeb https://xxx/964
$web
$webSub = Get-SPWeb https://xxx/964/sail

$publishingWeb = [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($web) 

#$nodes = $publishingWeb.Navigation.GlobalNavigationNodes

#This removes a link vice an entire site, they are treated differently
<#
for($i=$nodes.Count-1;$i -ge 0;$i--)
{
	if($nodes[$i].Title -eq "Other Helpful Links1")
	{
		$nodes[$i]
		#$nodes[$i].Delete()
	}
}
#>

#$publishingWeb.Navigation.IncludeInNavigation($false,$webSub.ID);#this shows the subsite in the Current Navigation Section
#$publishingWeb.Navigation.ExcludeFromNavigation($false,$webSub.ID);#this hides the subsite in the Current Navigation Section

#$publishingWeb.Navigation.IncludeInNavigation($true,$webSub.ID);#this shows the subsite in the Global Navigation Section
#$publishingWeb.Navigation.ExcludeFromNavigation($true,$webSub.ID);#this hides the subsite in the Global Navigation Section

#$publishingWeb.Navigation.ExcludeFromNavigation #shows the function parameters

$publishingWeb.Update() 
$web.Update()
$web.Close()  
$web.Dispose()
}

function Hide-GlobalSubsite
{
	Param ([string] $subwebUrl)

	$web = Get-SPWeb https://xxx/964
	write-host "Web $web"

	$webSub = Get-SPWeb $subwebUrl
	write-host "SubWeb $webSub"
	write-host "SubWeb ID " + $webSub.ID

	#https://xxx/964/sail

	$publishingWeb = [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($web) 

	$publishingWeb.Navigation.ExcludeFromNavigation($true,$webSub.ID);#this shows the subsite in the Global Navigation Section

	$publishingWeb.Update() 
	$web.Update()
	$web.Close()  
	$web.Dispose()
	write-host "Subsite Excluded from Global Navigation"
}

function Unhide-GlobalSubsite
{
	Param ([string] $subwebUrl)

	$web = Get-SPWeb https://xxx/964
	write-host "Web $web"

	$webSub = Get-SPWeb $subwebUrl
	write-host "SubWeb $webSub"
	write-host "SubWeb ID $webSub.ID"
	
	#https://xxx/964/sail

	$publishingWeb = [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($web) 

	$publishingWeb.Navigation.IncludeInNavigation($true,$webSub.ID);#this shows the subsite in the Global Navigation Section
	
	$publishingWeb.Update() 
	$web.Update()
	$web.Close()  
	$web.Dispose()
}

############Current Navigation Section - e.g. the Quick Launch###########################################

function Unhide-CurrentSubsite
{
	Param ([string] $subwebUrl)

	$web = Get-SPWeb https://xxx/964
	write-host "Web $web"

	$webSub = Get-SPWeb $subwebUrl
	write-host "SubWeb $webSub"
	write-host "SubWeb ID " + $webSub.ID

	#https://xxx/964/sail

	$publishingWeb = [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($web) 

	$publishingWeb.Navigation.IncludeInNavigation($false,$webSub.ID);#this shows the subsite in the Current Navigation Section

	$publishingWeb.Update() 
	$web.Update()
	$web.Close()  
	$web.Dispose()
	write-host "Subsite Included in Current Navigation"
}

function Hide-CurrentSubsite
{
	Param ([string] $subwebUrl)

	$web = Get-SPWeb https://xxx/964
	write-host "Web $web"

	$webSub = Get-SPWeb $subwebUrl
	write-host "SubWeb $webSub"
	write-host "SubWeb ID " + $webSub.ID

	#https://xxx/964/sail

	$publishingWeb = [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($web) 

	$publishingWeb.Navigation.ExcludeFromNavigation($false,$webSub.ID);#this shows the subsite in the Current Navigation Section

	$publishingWeb.Update() 
	$web.Update()
	$web.Close()  
	$web.Dispose()
	write-host "Subsite Excluded from Current Navigation"
}

function Remove-CurrentLinkChild
{
	Param ([string] $linkName, [bool] $displayOnly)
	
	$removed = ""
	$web = Get-SPWeb https://xxx/964
	$publishingWeb = [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($web)
	$nodes = $publishingWeb.Navigation.CurrentNavigationNodes
	$nodes | ForEach{
		$_.Children | ForEach{
				if($_.Title -eq $linkName)
				{
					if($displayOnly)
					{
						$_
					
					}
					else
					{
						$_.Delete()
						$publishingWeb.Update() 
						$web.Update()
						$web.Close()  
						$web.Dispose()
						$removed = $_.Title
						write-host "Web $web"
						write-host "Removed: $removed" -backgroundcolor "blue"
						break
					}
				}
				}#end second for each
	}#end first for each
	

	$publishingWeb.Update() 
	$web.Update()
	$web.Close()  
	$web.Dispose()

	write-host "Web $web"
	write-host "Removed: $removed" -backgroundcolor "blue"
}

function Remove-CurrentLink
{
	Param ([string] $linkName, [string] $displayOnly)

	$web = Get-SPWeb https://xxx/964
	$publishingWeb = [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($web)
	$nodes = $publishingWeb.Navigation.CurrentNavigationNodes
	for($i=$nodes.Count-1;$i -ge 0;$i--)
	{
		if($nodes[$i].Title -eq $linkName)
		{
			$nodes[$i]
			if($displayOnly -eq "No")
			{
				$nodes[$i].Delete()
				write-host "$linkName Deleted"
			}
		}
	}

$publishingWeb.Update() 
$web.Update()
$web.Close()  
$web.Dispose()

}

#Unhide-GlobalSubsite -subwebUrl https://xxx/964/Sail

#Hide-GlobalSubsite -subwebUrl https://xxx/964/sail
#Hide-GlobalSubsite -subwebUrl https://xxx/964/CPF

#Unhide-CurrentSubsite -subwebUrl https://xxx/964/sail
#Unhide-CurrentSubsite -subwebUrl https://xxx/964/CPF

#Hide-CurrentSubsite -subwebUrl https://xxx/964/supvr
#Hide-CurrentSubsite -subwebUrl https://xxx/964/964Containments
#Hide-CurrentSubsite -subwebUrl https://xxx/964/managers
#Hide-CurrentSubsite -subwebUrl https://xxx/964/FALL

#Remove-CurrentLink -linkName "Pictures" -displayOnly "No"
#Remove-CurrentLinkChild -linkName "Misc. Shared Documents" -displayOnly $false

function Remove-GlobalLink
{
#https://xx/399/964/cpf
$web = Get-SPWeb https://xx/300/399/964
$web
$webSub = Get-SPWeb https://xx/399/964/sail

$publishingWeb = [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($web) 

#$nodes = $publishingWeb.Navigation.GlobalNavigationNodes

#This removes a link vice an entire site, they are treated differently
<#
for($i=$nodes.Count-1;$i -ge 0;$i--)
{
	if($nodes[$i].Title -eq "Other Helpful Links1")
	{
		$nodes[$i]
		#$nodes[$i].Delete()
	}
}
#>

#$publishingWeb.Navigation.IncludeInNavigation($false,$webSub.ID);#this shows the subsite in the Current Navigation Section
#$publishingWeb.Navigation.ExcludeFromNavigation($false,$webSub.ID);#this hides the subsite in the Current Navigation Section

#$publishingWeb.Navigation.IncludeInNavigation($true,$webSub.ID);#this shows the subsite in the Global Navigation Section
#$publishingWeb.Navigation.ExcludeFromNavigation($true,$webSub.ID);#this hides the subsite in the Global Navigation Section

#$publishingWeb.Navigation.ExcludeFromNavigation #shows the function parameters

$publishingWeb.Update() 
$web.Update()
$web.Close()  
$web.Dispose()
}

function Hide-GlobalSubsite
{
	Param ([string] $subwebUrl)

	$web = Get-SPWeb https://xx/399/964
	write-host "Web $web"

	$webSub = Get-SPWeb $subwebUrl
	write-host "SubWeb $webSub"
	write-host "SubWeb ID " + $webSub.ID

	#https://xx/399/964/sail

	$publishingWeb = [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($web) 

	$publishingWeb.Navigation.ExcludeFromNavigation($true,$webSub.ID);#this shows the subsite in the Global Navigation Section

	$publishingWeb.Update() 
	$web.Update()
	$web.Close()  
	$web.Dispose()
	write-host "Subsite Excluded from Global Navigation"
}

function Unhide-GlobalSubsite
{
Param ([string] $subwebUrl)

$web = Get-SPWeb https://xx/399/964
write-host "Web $web"

$webSub = Get-SPWeb $subwebUrl
write-host "SubWeb $webSub"
write-host "SubWeb ID $webSub.ID"

#https://xx/399/964/sail

$publishingWeb = [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($web) 

$publishingWeb.Navigation.IncludeInNavigation($true,$webSub.ID);#this shows the subsite in the Global Navigation Section

$publishingWeb.Update() 
$web.Update()
$web.Close()  
$web.Dispose()
}

function Unhide-CurrentSubsite
{
	Param ([string] $subwebUrl)

	$web = Get-SPWeb https://xx/300/399/964
	write-host "Web $web"

	$webSub = Get-SPWeb $subwebUrl
	write-host "SubWeb $webSub"
	write-host "SubWeb ID " + $webSub.ID

	#https://xx/399/964/sail

	$publishingWeb = [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($web) 

	$publishingWeb.Navigation.IncludeInNavigation($false,$webSub.ID);#this shows the subsite in the Global Navigation Section

	$publishingWeb.Update() 
	$web.Update()
	$web.Close()  
	$web.Dispose()
	write-host "Subsite Included in Current Navigation"
}

function Remove-CurrentLinkChild
{
	Param ([string] $linkName, [bool] $displayOnly)
	
	$removed = ""
	$web = Get-SPWeb https://xx/399/964
	$publishingWeb = [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($web)
	$nodes = $publishingWeb.Navigation.CurrentNavigationNodes
	$nodes | ForEach{
		$_.Children | ForEach{
				if($_.Title -eq $linkName)
				{
					if($displayOnly)
					{
						$_
					
					}
					else
					{
						$_.Delete()
						$publishingWeb.Update() 
						$web.Update()
						$web.Close()  
						$web.Dispose()
						$removed = $_.Title
						write-host "Web $web"
						write-host "Removed: $removed" -backgroundcolor "blue"
						break
					}
				}
				}#end second for each
	}#end first for each
	

	$publishingWeb.Update() 
	$web.Update()
	$web.Close()  
	$web.Dispose()

	write-host "Web $web"
	write-host "Removed: $removed" -backgroundcolor "blue"
}

function Remove-CurrentLink
{
	Param ([string] $linkName, [string] $displayOnly)

	$web = Get-SPWeb https://homeportnw.psns.navy.mil/dept/300/399/964
	$publishingWeb = [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($web)
	$nodes = $publishingWeb.Navigation.CurrentNavigationNodes
	for($i=$nodes.Count-1;$i -ge 0;$i--)
	{
		if($nodes[$i].Title -eq $linkName)
		{
			$nodes[$i]
			if($displayOnly -eq "No")
			{
				$nodes[$i].Delete()
				write-host "$linkName Deleted"
			}
		}
	}

$publishingWeb.Update() 
$web.Update()
$web.Close()  
$web.Dispose()

}

#Remove-CurrentLink -linkName "Product Lines" -displayOnly "Yes"

#Unhide-GlobalSubsite -subwebUrl https://xx/964/Sail

#Hide-GlobalSubsite -subwebUrl https://xx/sail
#Hide-GlobalSubsite -subwebUrl https://xx/964/CPF

#Unhide-CurrentSubsite -subwebUrl https://xx/964/sail
#Unhide-CurrentSubsite -subwebUrl https://xx/964/CPF

Remove-CurrentLinkChild -linkName "Misc. Shared Documents" -displayOnly $false
function Remove-GlobalLink
{
#https://xx/964/cpf
$web = Get-SPWeb https://xx/300/399/964
$web
$webSub = Get-SPWeb https://xx/399/964/sail

$publishingWeb = [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($web) 

#$nodes = $publishingWeb.Navigation.GlobalNavigationNodes

#This removes a link vice an entire site, they are treated differently
<#
for($i=$nodes.Count-1;$i -ge 0;$i--)
{
	if($nodes[$i].Title -eq "Other Helpful Links1")
	{
		$nodes[$i]
		#$nodes[$i].Delete()
	}
}
#>

#$publishingWeb.Navigation.IncludeInNavigation($false,$webSub.ID);#this shows the subsite in the Current Navigation Section
#$publishingWeb.Navigation.ExcludeFromNavigation($false,$webSub.ID);#this hides the subsite in the Current Navigation Section

#$publishingWeb.Navigation.IncludeInNavigation($true,$webSub.ID);#this shows the subsite in the Global Navigation Section
#$publishingWeb.Navigation.ExcludeFromNavigation($true,$webSub.ID);#this hides the subsite in the Global Navigation Section

#$publishingWeb.Navigation.ExcludeFromNavigation #shows the function parameters

$publishingWeb.Update() 
$web.Update()
$web.Close()  
$web.Dispose()
}

function Unhide-GlobalSubsite
{
Param ([string] $subwebUrl)

$web = Get-SPWeb https://xx/300/399/964
write-host "Web $web"

$webSub = Get-SPWeb $subwebUrl
write-host "SubWeb $webSub"
write-host "SubWeb ID $webSub.ID"

#https://xx/399/964/sail

$publishingWeb = [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($web) 

$publishingWeb.Navigation.IncludeInNavigation($true,$webSub.ID);#this shows the subsite in the Global Navigation Section

$publishingWeb.Update() 
$web.Update()
$web.Close()  
$web.Dispose()
}

function Remove-CurrentLinkChild
{
	$web = Get-SPWeb https://xx/300/399/964
	$publishingWeb = [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($web)
	$nodes = $publishingWeb.Navigation.CurrentNavigationNodes
	$nodes | ForEach{
		$_.Children
	}
}

function Remove-CurrentLink
{
	Param ([string] $linkName, [string] $displayOnly)

	$web = Get-SPWeb https://xx/300/399/964
	$publishingWeb = [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($web)
	$nodes = $publishingWeb.Navigation.CurrentNavigationNodes
	for($i=$nodes.Count-1;$i -ge 0;$i--)
	{
		if($nodes[$i].Title -eq $linkName)
		{
			$nodes[$i]
			if($displayOnly -eq "No")
			{
				$nodes[$i].Delete()
				write-host "$linkName Deleted"
			}
		}
	}

$publishingWeb.Update() 
$web.Update()
$web.Close()  
$web.Dispose()

}

#Remove-CurrentLink -linkName "Product Lines" -displayOnly "No"

Unhide-GlobalSubsite -subwebUrl https://xx/964/Sail
#https://xxxx/site
$web = Get-SPWeb https://xxxx/site
$webSub = Get-SPWeb https://xxxx/site

$publishingWeb = [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($web) 

$nodes = $publishingWeb.Navigation.GlobalNavigationNodes

#This removes a link vice an entire site, they are treated differently
for($i=$nodes.Count-1;$i -ge 0;$i--)
{
	if($nodes[$i].Title -eq "Other Helpful Links1")
	{
		$nodes[$i]
		#$nodes[$i].Delete()
	}
}

#$publishingWeb.Navigation.IncludeInNavigation($false,$webSub.ID);#this shows the subsite in the Current Navigation Section
#$publishingWeb.Navigation.ExcludeFromNavigation($false,$webSub.ID);#this hides the subsite in the Current Navigation Section

#$publishingWeb.Navigation.IncludeInNavigation($true,$webSub.ID);#this shows the subsite in the Global Navigation Section
#$publishingWeb.Navigation.ExcludeFromNavigation($true,$webSub.ID);#this hides the subsite in the Global Navigation Section

#$publishingWeb.Navigation.ExcludeFromNavigation #shows the function parameters

$publishingWeb.Update() 
$web.Update()
$web.Close()  
$web.Dispose()
#https://xxx/300/399/964/cpf
$web = Get-SPWeb xxxx
$webSub = Get-SPWeb https://xxx

$publishingWeb = [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($web) 

#$publishingWeb.Navigation.IncludeInNavigation($false,$webSub.ID);#this shows the subsite in the Current Navigation Section
#$publishingWeb.Navigation.ExcludeFromNavigation($false,$webSub.ID);#this hides the subsite in the Current Navigation Section

#$publishingWeb.Navigation.IncludeInNavigation($true,$webSub.ID);#this shows the subsite in the Global Navigation Section
$publishingWeb.Navigation.ExcludeFromNavigation($true,$webSub.ID);#this hides the subsite in the Global Navigation Section

#$publishingWeb.Navigation.ExcludeFromNavigation #shows the function parameters

$publishingWeb.Update() 
$web.Update()
$web.Close()  
$web.Dispose()