Delete Navigation Node with Powershell from SharePoint Quicklaunch in all sites in a site collection
I'm trying to write a powershell script to go through all the sub sites in a site collection and remove a node that is no longer required.
I've placed my script below - but I'm getting an error on Get-SPWeb : The pipeline has been stopped - I'm thinking I may need to set a parameter to stop the pipe being closed? Any help is awesome!
$site = Get-SPSite http://sitecollurl
$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 "My User Profile")
{
$node.Delete()
}
}
$web.Dispose()
}