Powershell v2 and Sharepoint 2007 - Empty huge recycle bin - HOW?

Hi all
I need to delete the First and Second stage Recycle bin for all of our personal sites, as the total size of these has somehow exceeded 140GB.
I am however stuck as to how to do this. I have tried lots of Powershell scripts to get this done, but nothing has worked. I also tried to just switch off the Recycle Bin but this operation just times out, as the Bin is too large now for this to work.
My most recent Powershell script that I tried is the only one that didnt throw any errors and seemed to do something for about 6 seconds, but checking the recycle bin for the site I tried it against shows that it is still full:
param([string]$Url, [switch]$help)
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
function GetHelp()
$HelpText = @"
DESCRIPTION:
NAME: Remove-SPSiteSecondStageRecycleBin
Empties the second-stage recycle bin for a Microsoft.SharePoint.SPSite Collection
PARAMETERS:
-url Url to SharePoint Site Collection
SYNTAX:
Remove-SPSiteSecondStageRecycleBin -url http://ansafile
Empties the second stage recycle bin for the SiteCollection.
Remove-SPSiteSecondStageRecycleBin -help
Displays the help topic for the script
$HelpText
function Remove-SPSiteSecondStageRecycleBin([string]$url)
$siteCollection = New-Object Microsoft.SharePoint.SPSite($url);
$recycleQuery = New-Object Microsoft.SharePoint.SPRecycleBinQuery;
$recycleQuery.ItemState = [Microsoft.SharePoint.SPRecycleBinItemState]::SecondStageRecycleBin;
$recycleQuery.OrderBy = [Microsoft.SharePoint.SPRecycleBinOrderBy]::Default;
$recycledItems = $siteCollection.GetRecycleBinItems($recycleQuery);
$count = $recycledItems.Count;
for($i = 0; $i -lt $count; $i++)
$g = New-Object System.Guid($recycledItems[$i].ID);
$recycledItems.Delete($g);
$siteCollection.Dispose()
if($help) { GetHelp; Continue }
if($url) { Remove-SPSiteSecondStageRecycleBin -url $url }
After pressing Enter after adding the above, I then entered the below into Powershell:
Remove-SPSiteSecondStageRecycleBin -url http://ansafile
This seemed to do something, but not what I needed it to do, ie delete the recycle bin for the whole sharepoint installation. ANSAFILE is the internal name of the Sharepoint site. Also, I am using Powershell v2, in an ISE window. My server is running Windows
Server 2008 Std x64 edition. Sharepoint version is 12.0.0.6565
Hopefully someone can help, as I have never used Powershell before, and had to take over the Sharepoint which I have never done before either, and its a bit of a struggle
Thanks to all
Naz

Hi, I just tried the following Powershell script:
Add-PSSnapin Microsoft.SharePoint.PowerShell
$WebApp=get-spwebapplication "http://ansafile"
foreach ($SPSite in $webApp.Sites)
#get the collection of webs
foreach($SPWeb in $SPSite.AllWebs)
#Empty the 1st Stage Recycle bin items PERMENANTLY
#$SPWeb.RecycleBin.DeleteAll();
#Send the 1st Stage Recycle bin items to 2nd Stage
$SPWeb.RecycleBin.MoveAllToSecondStage();
write-host "End-User Recycle Bin Items Deleted for:"
write-host $SPWeb.title ":" $SPWeb.URL "`n"
#Empty SharePoint site collection recycle bin (Second Stage Recycle bin) or Admin Recycle bin
#$SPSite.RecycleBin.DeleteAll();
#write-host "Administrator Recycle bin Items Deleted for:" $SPSite.RootWeb.title "`n"
However, this results in the following error:
Add-PSSnapin : The Windows PowerShell snap-in 'Microsoft.SharePoint.PowerShell' is not installed on this machine.
At line:1 char:13
+ Add-PSSnapin <<<< Microsoft.SharePoint.PowerShell
+ CategoryInfo : InvalidArgument: (Microsoft.SharePoint.PowerShell:String) [Add-PSSnapin], PSArgumentException
+ FullyQualifiedErrorId : AddPSSnapInRead,Microsoft.PowerShell.Commands.AddPSSnapinCommand
The term 'get-spwebapplication' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included,
verify that the path is correct and try again.
At line:3 char:29
+ $WebApp=get-spwebapplication <<<< "http://ansafile"
+ CategoryInfo : ObjectNotFound: (get-spwebapplication:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
You cannot call a method on a null-valued expression.
At line:14 char:52
+ $SPWeb.RecycleBin.MoveAllToSecondStage <<<< ();
+ CategoryInfo : InvalidOperation: (MoveAllToSecondStage:String) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
Does this mean I need to install something called cmdlets?
Thanks
Naz

Similar Messages

  • I cant download a new tv episode because itunes says the disk is full that it is being stored on....however when I deleted many shows from my library it still will not download.....I went to my desktop and tried to empty my recycle bin and the empty recyc

    I cant download onto my computer an episode I purchased because when I hit download it says that the disk I am attempting to tranfer to is full.....however iy had no problem down loading another show....(Jon Stuart) So I went to my library where I see my shows stored and deleted MANY and when I tried again to download ---I got the same message to full......I tried to empty the recycle bin on my desktop thinking it was holding too much but the choice to empty is not darkened so it will not empty....can ANYONE help?

    Therefore, t there any way to just completely delete all the old backup data out of my Time Capsule from my prior Mac Laptop?
    Here is how to do this:
    Open Macintosh HD > Applications > Utilities > AirPort Utility
    Click Manual Setup
    Click the Disks icon at the top of the AirPort Utility window
    Click the Disks tab below the icons
    Click Erase
    The "Quick Erase" option will only take a moment or two
    Now you can backup your MacBook Pro. If you connect an Ethernet cable from the MBP to one of the LAN <-> ports on the TC, the first backup will go 3-5 times faster than wireless.
    Once you have the first backup done, you can use wireless for subsequent backups since they will only take a few minutes

  • I was trying to restore my itouch and when i pressed "restore" and then pressed "restore and update", another sign popped up saying "The ipod "ipod" could not be restored. The disk you are attempting is full. Removing files and empty the recycle bin

    i was trying to restore my itouch because it showed on my itouch the itunes bar on top and the charger on bottom so i went on itunes and when i pressed "restore" and then pressed "restore and update", another sign popped up saying "The ipod "ipod" could not be restored. The disk you are attempting is full. Removing files and empty the recycle bin will free up additional space. What do I do?!?!?! please help me ASAP

    Hi
    I followed this guy's instructions and it worked:
    http://evsiphone.blogspot.com/2009/05/iphone-iphone-could-not-be-restored.html
    I did disable the security (AVG and Zone Alarm) when I tried on my own PC. My wife's laptop which eventually got it working also uses AVG and Zone Alarm but on an XP O/S whereas my PC is Vista - maybe this is why.
    Cheers for you help.
    Andy
    Message was edited by: bigbadandy

  • I have a lock field(boot.efi) in recycle bin how to put it out (for unlock and empty my recycle bin)

    I have a lock field(boot.efi) in recycle bin how to put it out (for unlock and empty my recycle bin)

    Trying logging out/in or a restart.
    If that doesn't allow you to empty the trash:
    Trash – Empty When File is Locked or in Use
    Trash FAQ       
    Maybe this will help:
    https://discussions.apple.com/message/17029415#17029415

  • I keep getting an error code while trying to import a cd to my itunes: Error occurred while converting the file. The disc you are attempting to use is full. removing files and emptying the recycle bin will free up additional space.  What does this mean?

    I keep getting this error code while trying to import a cd to my itunes: "Error occurred while converting the file. The disc you are attempting to use is full. removing files and emptying the recycle bin will free up additional space."  What does this mean?

    Well it probably means exactly what it says... How much free space is there on your hard drive where the iTunes Media folder resides? I believe there is also an obscure bug that can occur when software doesn't read the true value of the free space properly, and the workaround is, perversely, to duplicate some content so that with less actual free space the software in question perceives it as more. I've no idea if iTunes is affected by such a bug.
    tt2

  • Every time i empty my recycle bin it comes up with error code -50. What can i do

    every time i empty my recycle bin it comes up with error code -50.

    Some trash tips:
    http://support.apple.com/kb/HT1526?viewlocale=en_US&locale=en_US
    http://osxdaily.com/2012/07/19/force-empty-trash-in-mac-os-x-when-file-is-locked -or-in-use/
    http://www.thexlab.com/faqs/trash.html
    http://fairerplatform.com/2013/10/force-empty-trash-os-x-mavericks/
    You can also download TrashIt, it can be helpful in stubborn situations:
    http://www.nonamescriptware.com/

  • Unable to download I have windows7. message keeps saying "empty recycle bin" how do I do that? thanks

    unable to download I have windows7. message keeps saying "empty recycle bin" how do I do that? thanks

    Its worth adding that if you deleted the song using iTunes, you will need to add the track to your library with File>>Add file to library" after restoring it from the recycle bin.

  • I had the problem of the Apple Sync Notifer.exe showing up every time I signed in.  I finally found it and deleted it and it is in my recycle bin but I am a bit nervous about totally deleting it.   Does anyone know if it is ok to completely delete??

    I had a problem with the Apple Sync Notifer.exe showing up every time I signed in.  I finally found a location and
    deleted it and it went into my recycle bin.  I was going to clean out the recycle bin and it asked if I really wanted to
    delete the Apple Sync Notifer.  I am wondering if it is safe to clear it or did I make an error and should keep it??

    Windows 7 can't run on Powerbooks.  The name of the computer is under the display on the frame.   Are you running some software in Boot Camp, or another virtualization engine?

  • HT201210 m not able to update i allready download latest verion of my phone but system telling me that remove files n empty the recycle bin what can i do i dont know

    m not able to update i allready download latest verion of my phone but system telling me that remove files n empty the recycle bin what can i do i dont know

    Then try a Safe Boot, (holding Shift key down at bootup), run Disk Utility in Applications>Utilities, then highlight your drive, click on Repair Permissions, reboot when it completes.
    (Safe boot may stay on the gray radian for a long time, let it go, it's trying to repair the Hard Drive.)
    Or If 10.7.0 or later...
    Bootup holding CMD+r, or the Option/alt key to boot from the Restore partitirion & use Disk Utility from there to Repair the Disk.

  • Windows 2003 Powershell and SharePoint 2007

    I know its old versions of a lot of things, but I need to run a Powershell script on a SharePoint 2007 list. I wrote the script and it works perfectly well if I run it under the SharePoint System Admin account. But as we all know updating a list item using
    this account does not start the associated workflow. So I tried running the script using different credentials. This user account has Portal Owner permissions but when the script tries to use New-Object cmdlet it fails. Can anyone tell me how I get the cmdlets
    available to this new user?
    Thanks

    You are trying to instantiate a New-Object of what type? Is it complaining about the New-Object cmdlet itself, or the actual object not being found in loaded assemblies?
    Nikolas Charlebois-Laprade Microsoft Certified Professional Software Engineer and Senior SharePoint Advisor http://nikcharlebois.com

  • Business Objects 3.0 and Sharepoint 2007

    We are currently upgrading from XI R2 to BO 3.0 and would like to use Sharepoint 2007.  I see a integration Kit for the XI R2 version but not for 3.0. What are our options, how can we utilize sharepoint 2007 ?

    We upgraded from Crystal Enterprise 10 to 3.0 only to find (even though all the documentation was there and we were encouraged to do so) that the Sharepoint2007 portal was not yet available. Last I heard was 3rd qtr 2008 or 1st qtr 2009 for availability.
    Since we have had many users download CR2008 and create reports that they wanted published this created a political nightmare.
    We have now fallen back to XI R2 just so we could implement the sp2007 portal kit.

  • Infopath 2007 and SharePoint 2007 error with Web Service Submit and Recieve

    I have an InfoPath form with code. The code submits the form to SharePoint and to SQL DB through Web Service. The form has some workflow. When form is in a "New" state if submits to SharePoint and Database through custom web service. Works fine
    from both Client and SharePoint browser form. The database ID is returned to the form and then stored in a field. In second stage of workflow additional fields are shown for Supervisor to fill out. I then have an "update" web service to update the
    database. I set all the field values in the Web service then execute both the update Web Service and the SharePoint submit. I get an error (both if running from desktop or SharePoint) Error is
    "The string '' is not a valid AllXsd value"     
    I know sometimes this happens with dates. But I've got all the dates set. The funny thing is in the first submit there are 2 dates in the second submit there is one date. All are set the same and on the first submit no problem submits correct dates to SQL
    database through web Service. Second submit has 2 Boolean fields that I also default to a value of false. I've debugged and looked at all the values and everything has a value. I use delete NIL to make sure value in Web Service is set. I can save the data
    in the form but not submit it because I get the web service error. If I save the data in form and download it and copy all the values in the XML to my Web Service and invoke the web service works fine. So there is no error in the web service. The first
    submit submits both dates and some integer values. The only difference in second is the Boolean value but it is set to default of false for all checkboxes.  I'm going out of mind trying to see what could be wrong.   Also difference with second
    is it sends in the ID of the record that was set in form by result of first submit query sending back the DB value. That value is an integer but I also set correctly.
    Susan J. Swanger

    Hi Somatco,
    According to your description, my understanding is that you got an error when you ran report with xml type datasource.
    Please set the xml datasource credential to Use Windows Authentication (integrated security). More information, please refer to the link:
    http://social.technet.microsoft.com/Forums/sqlserver/en-US/530c29ab-7ed5-4c36-816a-910c0b51f4bd/xml-data-source-unable-to-authenticate-using-windows-authentication?forum=sqlreportingservices
    Here are some similar posts for you to take a look at:
    http://www.symantec.com/business/support/index?page=content&id=TECH190935
    http://social.msdn.microsoft.com/Forums/en-US/285e4e8c-d05c-48f8-b4f3-9d87988d823e/an-error-has-occurred-during-report-processing-rsprocessingaborted-query-execution-failed-for?forum=sqlreportingservices
    In addition, as this issue is related to SQL Server Reporting, I commend you create a new thread in SQL Server Reporting forum, more experts will assist you with SQL Server Reporting.
    SQL Server Report forum:
    http://social.msdn.microsoft.com/Forums/sqlserver/en-US/home?forum=sqlreportingservices
    I hope this helps.
    Thanks,
    Wendy
    Wendy Li
    TechNet Community Support

  • I can't empty my recycle bin

    Can any one help me with emptying my macbook recycle bin.
    Thanks in advance

    Try what this web site says.
    http://www.thexlab.com/faqs/trash.html
    Allan

  • I accidentally deleted a song and it's in the recycle bin.  How do I get it back in my music library?

    I have a deleted song in the recycle bin that I'd like to restore to my  iTunes library.  How do I  do this?  Thanks for the help.
    JodyfromMarmora

    Its worth adding that if you deleted the song using iTunes, you will need to add the track to your library with File>>Add file to library" after restoring it from the recycle bin.

  • ACE 4710 Lbs and SharePoint 2007 issues

    We have 2 4710 ACE boxes servicing our Sharepoint farm.  Users try to go to Sharepoint will get a page not displayed.  We have to add ahost file to one of the sharepoint webservers and then they work just fine and get their data.  We have looked and the config is very simple for the ACE.  Any ideas on what can be causing this?

    "We have to add a host file to the sharepoint server" -
    Do you mean you are putting the DNS name of the sharepoint server into the host file on the client which is accessing the loadbalancer?
    If so - there are non-relative links or redirects occuring.
    If its a redirect, ACE can rewrite the Location header if its HTTP between the ACE and the server.
    Can you share your config on your ACE?
    -Chris

Maybe you are looking for