I would like to use the Remove-Item function from SPE, but I want to be notified before I delete an item which is referenced by another item(s). I mean the window above when I would like to remove an item from Content Editor:

enter image description here

1 Answer 1


You can invoke the BreakingLinks dialog from SPE using the Show-ModalDialog command. This command will return yes or no as a value, depending on whether the user decided to complete the dialog or cancel out of it.

Here is an example script that checks for item references of each item it will delete, and if there are any, it launches the dialog. Cancelling out of the dialog will mean the item is skipped from being deleted.

$items = Get-ChildItem -Path master:/sitecore/content/Home

foreach ($item in $items)
    # Determine if any items refer to this item
    if (Get-ItemReferrer -Item $item)
        # Show the broken links dialog
        $result = Show-ModalDialog -Control "BreakingLinks" -HandleParameters @{ list = $item.Id }

        # If user cancels dialog, do not proceed with deleting this item
        if ($result -eq "no") {

    Write-Host "Deleting $($item.Paths.FullPath)"
    $item | Remove-Item

There are likely some cases to deal with, such as how to handle items with descendants, but this should be enough to get you going. This has had very little testing so I would encourage you test thoroughly before using.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.