Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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.

share|improve this question
    
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

2 Answers 2

up vote 5 down vote accepted

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.

Install-SPSolution
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

Uninstall-SPSolution:

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

share|improve this answer
    
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
2  
I ran .NET Relector against Microsoft.SharePoint.PowerShell.dll in GAC –  Per Jakobsen 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) –  Anders Rask 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
share|improve this answer
    
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 –  Falak Mahmood 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? –  Falak Mahmood Jul 25 '12 at 22:43

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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