locked
PowerShell disable feature -- How to run it quietly RRS feed

  • Question

  • I wrote this line

    Disable-SPFeature -identity $feature

    Confirm
    Are you sure you want to perform this action?
    Performing operation "Disable-SPFeature" on Target "Farm Scope |ff48f7e6-2fa1-428d-9a15-ab154762043d".
    [Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "Y"): Y

     

    I don't want this prompt to block my script... the script should run quietly. The answer to all promts is Yes. How can I make this run quietly without asking "are you sure" type of questions?

    Monday, March 28, 2011 1:24 PM

Answers

  • Did you try the flag : -Confirm:$false
    • Marked as answer by MSDN Student Monday, March 28, 2011 3:49 PM
    Monday, March 28, 2011 2:02 PM

All replies

  • Did you try the flag : -Confirm:$false
    • Marked as answer by MSDN Student Monday, March 28, 2011 3:49 PM
    Monday, March 28, 2011 2:02 PM
  • Disable-SPFeature -identity $feature -Confirm $false
    Disable-SPFeature : A positional parameter cannot be found that accepts argument 'False'.
    At line:1 char:18
    + Disable-SPFeature <<<<  -identity $feature -Confirm $false
        + CategoryInfo          : InvalidArgument: (:) [Disable-SPFeature], ParameterBindingException
        + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.SharePoint.PowerShell.SPCmdletDisableFeature
    Monday, March 28, 2011 2:11 PM
  • Hi MSDN Student,

    Apparently you missed the colon (:) when assigning the $false value to the -Confirm switch.

    If you do that, the cmdlet should work as expected.

    Best regards,

    Martin


    Martin W. Angler, MCTS

    Blog angler.wordpress.com
    Twitter: martinangler
    Monday, March 28, 2011 2:21 PM
  • Try :

    $confirmflag = $false;

     ...... -Confirm: $confirmflag

    Monday, March 28, 2011 2:52 PM
  • Does it change anything w.r.t. -confirm:$false?

     

    Best,

    Martin


    Martin W. Angler, MCTS

    Blog angler.wordpress.com
    Twitter: martinangler
    Monday, March 28, 2011 2:56 PM
  • @Martin : You are right. $true are part of standard variables.

    But as a scripting best practice, it is recommended to assign values and use them.

    Monday, March 28, 2011 3:23 PM