2

I'm running a PowerShell script that deletes about 10 entries per minute. Is there a way to do this more efficiently/quicker, i.e. directly from the database? How can this be achieved?

$web = Get-SPWeb http://site
$qlNave = $web.Navigation.QuickLaunch
$i = 1
ForEach ($Node in $qlNave)
{
  if ($node.Title -eq "something")
  {
    $node.Delete()
  }
  $i++
}
$web.Dispose()

Thanks!

2 Answers 2

3

I did it with the following code,

Add-PSSnapin Microsoft.Sharepoint.Powershell
$FindString = “something”
Get-SPSite http:/sitecollectionurl/ | get-spweb -limit all | foreach-object{
    $web = $_
    $_.Navigation.QuickLaunch | ForEach-Object {
        $_.Children | ForEach-Object {
            if($_.title -eq $FindString){
                $node = $_
                $node.delete()
                Write-Host “Deleted node from ” $web “-” $web.url
                }
            }
       }
  }

Remove-PsSnapin Microsoft.SharePoint.PowerShell

OR

try the below codes too

To delete the link from the Quick Launch

Add-PSSnapin Microsoft.Sharepoint.Powershell
$webURL="http://serverName:1111/sites/SPSiteDataQuery/"
$web=Get-SPWeb $webURL
$navigationNodeColl=$web.Navigation.QuickLaunch
$heading = $navigationNodeColl | where { $_.Title -eq "Libraries" }
$link = $heading.Children | where { $_.Title -eq "Shared Documents" }
$link.Delete()
Remove-PsSnapin Microsoft.SharePoint.PowerShell

To delete the heading from the Quick Launch

Add-PSSnapin Microsoft.Sharepoint.Powershell
$webURL="http://serverName:1111/sites/SPSiteDataQuery/"
$web=Get-SPWeb $webURL
$navigationNodeColl=$web.Navigation.QuickLaunch
$heading = $navigationNodeColl | where { $_.Title -eq "Libraries" }
$heading.Delete()
Remove-PsSnapin Microsoft.SharePoint.PowerShell

Source

1
$subsite= Get-SPWeb $subSiteUrl

$node = $subsite.Navigation.QuickLaunch | where { $_.TitleResource.Value -eq $titleToRemove}

if($node -ne $null)
{
   $node.Delete()
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.