Hi I've put this question up here : https://stackoverflow.com/questions/13130785/delete-navigation-node-with-powershell-from-sharepoint-quicklaunch-in-all-sites but no answer yet so posting here too.
I've put together a powershell script to delete a specific quicklaunch node in sharepoint 2010. It works on a dummy site collection, but fails on another (migrated sites from sp2007).
Here is the script:
Add-PSSnapin Microsoft.SharePoint.PowerShell -erroraction SilentlyContinue
$site = Get-SPSite http://site.com/SITES/OFFICES/
$site | get-spweb -limit all | foreach-object{
$webURL = $_.url
$web = Get-SPWeb $webURL
$navigationNodes = $web.Navigation.QuickLaunch
ForEach ($Node in $NavigationNodes)
{
if($node.Title -eq "People and Group")
{
write-host $web.URL "...node exists here"
{continue}
$node.Delete()
$web.update()
write-host $web.URL "...node removed"
}
}
$web.Dispose()
}
The error I get when running as SP_Admin is :
Get-SPWeb : The pipeline has been stopped. At line:3 char:18 + $site | Get-SPWeb <<<< -limit all | foreach-object { + CategoryInfo : InvalidData: (Microsoft.Share....SPCmdletGetWeb:SPCmdletGetWeb) [Get-SPWeb], PipelineStoppedException + FullyQualifiedErrorId : Microsoft.SharePoint.PowerShell.SPCmdletGetWeb
ForEach-Object : Cannot complete this action.
Please try again. At line:3 char:46 + $site | Get-SPWeb -limit all | foreach-object <<<< { + CategoryInfo : NotSpecified: (:) [ForEach-Object], SPException + FullyQualifiedErrorId : Microsoft.SharePoint.SPException,Microsoft.PowerShell.Commands.ForEachObjectCommand
I am new to powershell so trying to debug the issue - do I need to build an array of the nodes before deleting them?
Any guidance would be great. Thanks Rich