Hi All,
In a following post we will see about how to delete/Add Top
Navigation Links using Powershell script in SharePoint.
Code Snippet for
Deletion:
if(!(Get-PSSnapin Microsoft.SharePoint.PowerShell
-ea 0))
{
Add-PSSnapin Microsoft.SharePoint.PowerShell
}
$web=Get-SPWeb "http://xyz"
$nodeColl = $web.Navigation.TopNavigationBar
[int]$count=$nodeColl.Count
Write-Host $count
Write-Warning "Deleting
Top Menu Links "
while($count
-ne 0)
{
$nodeColl[$count-1].Delete()
$count--
}
$web.Update();
$web.Dispose();
Write-Host "Process
Done..!!"
Code Snippet for Adding:
if(!(Get-PSSnapin Microsoft.SharePoint.PowerShell
-ea 0))
{
Add-PSSnapin Microsoft.SharePoint.PowerShell
}
$web=Get-SPWeb "http://xyz"
$nodeColl = $web.Navigation.TopNavigationBar
$node=New-Object Microsoft.SharePoint.Navigation.SPNavigationNode("Google",
"www.google.com")
$nodeColl.AddAsLast($node)
$node=New-Object Microsoft.SharePoint.Navigation.SPNavigationNode("Facebook",
"www.facebook.com")
$nodeColl.AddAsLast($node)
$node=New-Object Microsoft.SharePoint.Navigation.SPNavigationNode("Twitter",
"www.twitter.com")
$nodeColl.AddAsLast($node)
$web.Update()
$web.Dispose()
Hope
it useful,
Thanks.
Please just wanted to confirm if this script does not delete site content or site collections
ReplyDelete