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.
Related Post
Powershell
- Delete Quick Links using Powershell
- Get CheckedOut Files from SharePoint 2013 and MOSS2007
- PowerShell::Get Content Database Size in SharePoint
- PowerShell :: Delete All List Items
- Powershell :: Apply Master Page to all sub sites under site collection
- Get Site Collections specific to a Content Database and Export to CSV
- Remove-SPSite 0x80070003 - Forcely delete Site Collection that cannot be deleted
- Check Whether PowerShell Process is 32-bit or 64-bit?
- How to send Email by using Powershell in SharePoint
- Create Site Column Using Power Shell and Server Object Model
- Admin SVC must be running in order to create deployment timer job
- WSP Deployments in SharePoint using Powershell
- Create Site Collection by using Power Shell
- Create Web Application by using Powershell
- Backup Site Collection/Sub site/List(Library) in Share Point
- Get Site Collection Details using STSADM
- WSP Backup from Central Administration in Share Point
- Deactivate/Delete Site Template through Power shell
Please just wanted to confirm if this script does not delete site content or site collections
ReplyDelete