Question

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.

Was it helpful?

Solution

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

OTHER TIPS

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
Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top