0

I am using Batch Delete using Powershell.

After batch delete, items are moved to recycle bin. spWeb.RecycleBin.DeleteAll(); will delete all items from recycle bin. Instead, i want to remove only those items which i have batch deleted.

For that, i came across a command spWeb.RecycleBin.Delete(Guid[] ids); but i am missing something while implementing it. As a result i am getting error :

Exception calling "Delete" with "1" argument(s): "Specified argument was out of the range of valid values.Parameter name: ids"

Following is the PowerShell Code used to achieve the same:

[Guid]$a = "fcfdc7d3-ef59-4988-b3e9-0ae7184c6c4f" (Sample GUID Present in recycle bin)
$deletions = New-Object Collections.Generic.List[System.Guid];
$deletions.Add($a)
$ArchiveWeb.RecycleBin.Delete($deletions.ToArray());

What i am missing here?

3
  • Have you tried calling Delete on the Item instead of on the collection? May 21, 2015 at 13:31
  • Yes i did.In that case, it does not move to recycl But it takes too much time. I have to delete more than 1 lakh records at a go.So i performed Batch Delete.
    – 404
    May 21, 2015 at 13:52
  • I was thinking about the SPRecycleBinItem in the RecycleBin May 21, 2015 at 13:54

2 Answers 2

0

I wonder if you're creating your guid in the correct manner? Try this:

$a = [System.Guid]"fcfdc7d3-ef59-4988-b3e9-0ae7184c6c4f"
2
  • Thanks. I was not sure what is correct syntax for this. I will try this and update.
    – 404
    May 21, 2015 at 13:48
  • I am curious to know if this worked as I've never tried it myself?
    – Submits
    May 27, 2015 at 14:43
0

try the below code:

   $sitecol = get-spsite “http://lmbsrhzwsp”  
    $deletions = new-object system.guid("fcfdc7d3-ef59-4988-b3e9-0ae7184c6c4f")   
    $sitecol.recyclebin.delete($guid)

Clean Recycle Bin through Powershell in High Turnover Sharepoint Site

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.