When I try to uninstall WSP with following line, everything is ok:

Uninstall-SPSolution project.wsp # no error - OK

When I try to add switch parameter -AllWebApplications, I get error (something like This solution doesn't contains any resources for Web Application scope), which is also fine:

Uninstall-SPSolution project.wsp -AllWebApplications # error X - OK

BUT, when I add that switch parameter with FALSE value, I get error (same as above), which is wrong, isn't it?

Uninstall-SPSolution project.wsp -AllWebApplications:$false # error X again - WRONG

It looks like nothing changed from the line before this one, but it should...

In another way: My solution do NOT need AllWebApplication parameter, but I want to explicitly turn it off (meaning - specify it with FALSE value).

Question is: How can I specify this switch parameter as FALSE?

I just noticed that this is not happening with cmdlet Install-SPSolution.

  • What is the error message you get when using -AllWebApplications:$false?
    – Russell
    Jul 25 '12 at 22:39
  • I added error message to the Q. But it is translated...
    – jumbo
    Jul 25 '12 at 23:02

It seems as if Install-SPSolution and Uninstall-SPSolution has been written by two different developers (or at least at different times)

Both commands have the potential of accepting either no, a single or all WebApplications how they deal with these option are quiet different.

This is the well coded one, where the decision is base on:

  • Check to see if it got a non null value in WebApplication, if so it checks for AllWebApplications being true if it is then it's an error, if not it's a single WebApp
  • if not single, it checks to see if the SwitchParameter AllWebApplications is true, if so it's all WebApps
  • if not then it's no WebApps


Has assigned different parametersets to the two parameters, that means you can't specify both -WebApplication and -AllWebApplications regardless of values as it then can't decide which parameterset you mean.

And then to "Your bug" instead of checking for the value of -AllWebApplications they just check if the parameterset is "AllWebApplication" if so they ignore any value you specified and just assumes true

  • That explains that weird behavior! I want to use some swear-words, it take two hours of my life!!! Just one thing - can you share the source of your information? So I can check such things myself in the future. Thanks.
    – jumbo
    Jul 27 '12 at 7:42
  • 3
    I ran .NET Relector against Microsoft.SharePoint.PowerShell.dll in GAC Jul 27 '12 at 7:54
  • 3
    Good answer. Bonus info: i get the impression that you are trying to script a single approach to install/uninstall solutions. Remember that you can check if a solution contains WebApplication ressources, and hence needs either -AllWebApplication or -WebApplication parameter, using $solution.ContainsWebApplicationResource and then act accordingly (eg omitting -AllWebApplications instead of setting it to $false) Jul 27 '12 at 7:56
  • 2PerJakobsen: thanks for that info, that's what I needed to know (sounds like I should have known that :) ). @AndersRask That is nice. I didn't know that (obviously). Even I didn't ask that, that is what I needed. Thank you.
    – jumbo
    Jul 27 '12 at 8:27

It should work by setting -confirm to 0 or false.

From all web applications:

Uninstall-SPSolution yousolutionname.wsp -AllWebApplications -Confirm:$false

From a specific web application:

Uninstall-SPSolution -Identity yousolutionname.wsp -Confirm:0 -Webapplication $url
  • I didn't mentioned confirm parameter, but AllWebapplications parameter. I need to explicilty turn off the AllWebAplications parameter. You do not turn off that parameter in your examples.
    – jumbo
    Jul 25 '12 at 21:59
  • I slightly edited my question to be more clear.
    – jumbo
    Jul 25 '12 at 22:27
  • Uninstall-SPSolution cmdlet retracts a deployed SharePoint solution in preparation for removing it from the farm entirely. Which means you may either specify the retraction of solution for all globally deployed solutions, or from all the web applications or from a specific web application. The same applies to Install-SPSolution Jul 25 '12 at 22:31
  • I didn't ask for explanation of parameters. I asked for explanation of BAD/WEIRD behavior of Uninstall-SPSolution when using FALSE value for AllWebApplications parameter.
    – jumbo
    Jul 25 '12 at 22:36
  • Thanks for the edit, now I got your question :). have you specified 0? What error message you got? Jul 25 '12 at 22:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.