locked
How to set recycle bin retention period for spo 2013 using powershell script RRS feed

  • Question

  • Running below powershell script on version 3.0 and window 7.

    #Get current RecycleBinRetentionPeriod 
    $Currentday = $webapp.RecycleBinRetentionPeriod 
    #Get user's choice 
    $result = GetChoice $Currentday $Day 
    #If 'yes', execute the script 
    if($result -eq  0 ) 

        $webapp.RecycleBinRetentionPeriod = $Day 
        $webapp.update() 
        write-host "Set RecycleBinRetentionPeriod to $Day successfully. " 

    Else 

        write-warning "Action cancelled by user." 
    }

    I got this error

    etChoice : The term 'GetChoice' 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:4 char:11

    + $result = GetChoice $Currentday $Day

    +           ~~~~~~~~~

        + CategoryInfo          : ObjectNotFound: (GetChoice:String) [], CommandNotFoundException

        + FullyQualifiedErrorId : CommandNotFoundException

    Wednesday, April 20, 2016 8:13 PM

Answers

  • Sorry, but you will need to research this yourself.


    -- Bill Stewart [Bill_Stewart]

    • Marked as answer by AP1003 Thursday, April 21, 2016 1:45 PM
    Thursday, April 21, 2016 12:07 AM
  • Do you mean SharePoint Online? (ie. Office 365) If so then you cannot modify this setting in any way. The SPO web app level configuration options are not available remotely.

    Whilst there are basic syntax errors (lots of them) you are trying to do something that cannot be done.


    • Edited by Alex Brassington Thursday, April 21, 2016 7:58 AM
    • Marked as answer by AP1003 Thursday, April 21, 2016 1:45 PM
    Thursday, April 21, 2016 7:57 AM

All replies

  • The error is pretty clear. There is no such command as GetChoice.

    Wednesday, April 20, 2016 8:17 PM
  • First, try reading the error message.

    The term 'GetChoice' is not recognized as the name of a cmdlet, function, script file, or operable program.

    Other programming languages would say something like "unknown identifier."

    In other words: You do not have a program, function, or cmdlet called "GetChoice".


    -- Bill Stewart [Bill_Stewart]

    Wednesday, April 20, 2016 8:19 PM
  • I am using SPO 2013. What other cmdlet can I use to accomplish this task?

    Thank you for your reply.

    Alpa

    Wednesday, April 20, 2016 8:30 PM
  • What other cmdlet can I use for SPO 2013?

    Thank you for your quick reply.

    alpa

    Wednesday, April 20, 2016 8:30 PM
  • Sorry but your question doesn't make any sense.

    If this is a SharePoint question, you should probably ask in the SharePoint forum.


    -- Bill Stewart [Bill_Stewart]

    Wednesday, April 20, 2016 8:42 PM
  • Sorry for any confusion ! What I am looking for a powershell script to prevent extend number of day in primary and secondary recycle bin setting to either 150 days or 200 days. Above script can be accomplished but it's not working.

    do you have script or direct me to a website where I can the information.

    Thanks

    alpa

    Wednesday, April 20, 2016 11:25 PM
  • Sorry, but you will need to research this yourself.


    -- Bill Stewart [Bill_Stewart]

    • Marked as answer by AP1003 Thursday, April 21, 2016 1:45 PM
    Thursday, April 21, 2016 12:07 AM
  • Its a language issue. :prevent" should be "set".

    Here are numerous articles explaining how this is done.

    https://www.google.com/?gws_rd=ssl#newwindow=1&q=powershell+How+to+set+recycle+bin+retention+period+for+spo+2013+using+powershell+script


    \_(ツ)_/

    Thursday, April 21, 2016 12:20 AM
  • Do you mean SharePoint Online? (ie. Office 365) If so then you cannot modify this setting in any way. The SPO web app level configuration options are not available remotely.

    Whilst there are basic syntax errors (lots of them) you are trying to do something that cannot be done.


    • Edited by Alex Brassington Thursday, April 21, 2016 7:58 AM
    • Marked as answer by AP1003 Thursday, April 21, 2016 1:45 PM
    Thursday, April 21, 2016 7:57 AM
  • Yes in SPO/0365 2013. I thought so that you can't modify but though of asking if there are any work around to it. Either using powershell or csom script.

    Thank you for your response.

    Alpa

    Thursday, April 21, 2016 1:45 PM
  • I had visited these articles but it does not work on SPO/o365 environment. Any other suggestion would be very helpful

    Thursday, April 21, 2016 6:46 PM