none
Run Remove-MailboxExportRequest unattended

    Question

  • I made a powershell script to delete all completed export mailbox requests.
    The script to be executed is: "Get-MailboxExportRequest -Status Completed | Remove-MailboxExportRequest"
    The script is executed using a command file; it works fine, however it asks me to confirm the action manualy.

    Is there a way to run it without confirming the action, so I can run it as a shedualed task?

    Friday, August 26, 2011 8:32 AM

Answers

  • Try

    Get-MailboxExportRequest -Status Completed | Remove-MailboxExportRequest -Confirm $false

    Karl


    My Blog: http://unlockpowershell.wordpress.com
    My Book: Windows PowerShell 2.0 Bible
    My E-mail: -join ("6B61726C6D69747363686B65406D742E6E6574"-split"(?<=\G.{2})",19|%{[char][int]"0x$_"})
    • Marked as answer by IamMred Saturday, September 10, 2011 7:21 AM
    Monday, August 29, 2011 3:07 PM
  • Here is the complete explanation:

    $ConfirmPreference
    ------------------
      Determines which cmdlet actions automatically request confirmation
      from the user before they are performed.
    
      When the $ConfirmPreference value (High, Medium, Low, None) is
      greater than or equal to the risk of the cmdlet action (High, Medium,
      Low, None), Windows PowerShell automatically requests confirmation
      from the user before performing the action.
    
      You can use the Confirm parameter of a cmdlet to override the preference
      for a specific command.
    
        Valid values:
            None:  No cmdlet actions are automatically confirmed.
                 Users must use the Confirm parameter to request
                 confirmation of specific commands.
    
            Low:   Cmdlet actions with a low, medium, or high risk are
                 automatically confirmed. To suppress confirmation
                 of a specific command, use -Confirm:$false.
    
            Medium: Cmdlet actions with a medium or high risk are
                 automatically confirmed. To enable confirmation of
                 a specific command, use -confirm. To suppress
                 confirmation of a specific command, use
                 -confirm:$false.
    
            High:  Cmdlet actions with a high risk are automatically
           (default) confirmed. To enable confirmation of a specific
                 command, use -confirm. To suppress confirmation for a
                 specific command, use -confirm:$false.
    
    
      DETAILED EXPLANATION
        When a cmdlet action significantly affects the system, such as by
        deleting data or by using a significant amount of system resources,
        Windows PowerShell can automatically prompt you for confirmation
        before performing the action.
    
        For example,
    
          PS> remove-item pref2.txt
    
          Confirm
          Are you sure you want to perform this action?
          Performing operation "Remove File" on Target "C:\pref2.txt".
          [Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"):
    
        The estimate of the risk is part of the cmdlet known as its
        "ConfirmImpact". You cannot change it.
    
        Cmdlet that might pose a risk to the system have a Confirm parameter
        that you can use to request or suppress confirmation for a
        specific command.
    
        Because most cmdlets use the default risk value of Medium, and the
        default value of $ConfirmPreference is High, automatic confirmation
        rarely occurs. However, you can activate automatic confirmation by
        changing the value of $ConfirmPreference to Medium or Low.

     


    jv
    • Marked as answer by IamMred Saturday, September 10, 2011 7:21 AM
    Friday, August 26, 2011 1:55 PM

All replies

  • I don’t have access to my dev environment to try it but have you tried tacking a "-confirm $false" to the end of the command?

    Friday, August 26, 2011 12:04 PM
  • Thanks,

    I have tested it, but it does not help.
    This is what the command displays:

    C:\Prog\Backup>powershell -PSConsoleFile "C:\Program Files\Microsoft\Exchange Server\V14\Bin\exshell.psc1" -command "C:\Prog\Backup\RemoveBackupRequestExchange.ps1" -NonInteractive -confirm $false  1>C:\Prog\Backup\RemoveBackupRequestExchange.log

    Confirm
    Are you sure you want to perform this action?
    Removing completed request 'reijngoud.local/MyBusiness/Users/SBSUsers/Rob
    Reijngoud\MailboxExport'.
    [Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help
    (default is "Y"):

    You stil have to type 'A' to proceed.


    Met vriendelijke groeten, Bert Sannes
    Friday, August 26, 2011 1:22 PM
  • $WarningPreference
    $ConfirmPreference

    What is it set to?


    jv
    Friday, August 26, 2011 1:51 PM
  • Here is the complete explanation:

    $ConfirmPreference
    ------------------
      Determines which cmdlet actions automatically request confirmation
      from the user before they are performed.
    
      When the $ConfirmPreference value (High, Medium, Low, None) is
      greater than or equal to the risk of the cmdlet action (High, Medium,
      Low, None), Windows PowerShell automatically requests confirmation
      from the user before performing the action.
    
      You can use the Confirm parameter of a cmdlet to override the preference
      for a specific command.
    
        Valid values:
            None:  No cmdlet actions are automatically confirmed.
                 Users must use the Confirm parameter to request
                 confirmation of specific commands.
    
            Low:   Cmdlet actions with a low, medium, or high risk are
                 automatically confirmed. To suppress confirmation
                 of a specific command, use -Confirm:$false.
    
            Medium: Cmdlet actions with a medium or high risk are
                 automatically confirmed. To enable confirmation of
                 a specific command, use -confirm. To suppress
                 confirmation of a specific command, use
                 -confirm:$false.
    
            High:  Cmdlet actions with a high risk are automatically
           (default) confirmed. To enable confirmation of a specific
                 command, use -confirm. To suppress confirmation for a
                 specific command, use -confirm:$false.
    
    
      DETAILED EXPLANATION
        When a cmdlet action significantly affects the system, such as by
        deleting data or by using a significant amount of system resources,
        Windows PowerShell can automatically prompt you for confirmation
        before performing the action.
    
        For example,
    
          PS> remove-item pref2.txt
    
          Confirm
          Are you sure you want to perform this action?
          Performing operation "Remove File" on Target "C:\pref2.txt".
          [Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"):
    
        The estimate of the risk is part of the cmdlet known as its
        "ConfirmImpact". You cannot change it.
    
        Cmdlet that might pose a risk to the system have a Confirm parameter
        that you can use to request or suppress confirmation for a
        specific command.
    
        Because most cmdlets use the default risk value of Medium, and the
        default value of $ConfirmPreference is High, automatic confirmation
        rarely occurs. However, you can activate automatic confirmation by
        changing the value of $ConfirmPreference to Medium or Low.

     


    jv
    • Marked as answer by IamMred Saturday, September 10, 2011 7:21 AM
    Friday, August 26, 2011 1:55 PM
  • Try

    Get-MailboxExportRequest -Status Completed | Remove-MailboxExportRequest -Confirm $false

    Karl


    My Blog: http://unlockpowershell.wordpress.com
    My Book: Windows PowerShell 2.0 Bible
    My E-mail: -join ("6B61726C6D69747363686B65406D742E6E6574"-split"(?<=\G.{2})",19|%{[char][int]"0x$_"})
    • Marked as answer by IamMred Saturday, September 10, 2011 7:21 AM
    Monday, August 29, 2011 3:07 PM
  • Try

    $a= "A"
    Get-MailboxExportRequest -Status Completed | Remove-MailboxExportRequest -Confirm $a
    This always works for me.
    Monday, January 30, 2012 3:52 PM
  • User this...  -Confirm:$false

    Get-MailboxExportRequest -Status Completed | Remove-MailboxExportRequest -Confirm:$false

    • Proposed as answer by travgonz Wednesday, July 31, 2013 12:08 AM
    Tuesday, May 8, 2012 6:40 PM
  • Worked a bloomin charm @GreggCannon :)

    • Edited by DrNavratil Thursday, November 19, 2015 8:52 AM
    Thursday, November 19, 2015 8:49 AM
  • This is it! Thank you so much!
    Tuesday, January 26, 2016 11:33 PM
  • This works perfect, thanks!!!
    Saturday, January 12, 2019 10:25 AM
  • Please do not reply to old and already answered threads just to say thanks. That does not serve any benefit at all.

    Thanks


    Live long and prosper!

    (79,108,97,102|%{[char]$_})-join''

    Saturday, January 12, 2019 11:05 AM