Joel's SharePoint Architect Blog

SharePoint 2013 Training, Architecture, Administration and Development

Subscribe Subscribe  View Joel Jeffery's profile on LinkedIn
joelblogs.co.uk | joelj.co.uk | joeljeffery.co.uk | jfdiphoenix.co.uk

Category : Uncategorized

SharePoint 2013 Article Published on TechNet

I’ve just had an article published on Microsoft TechNet!

http://blogs.technet.com/b/uktechnet/archive/2013/05/07/guest-post-distributed-cache-service-in-sharepoint-2013.aspx

A little article about the Distributed Cache Service in SharePoint 2013.

I frequently need to tear down and rebuild the SharePoint 2010 environment I use for demonstrations.

One action I need to perform pretty much weekly is removing all the installed SharePoint solutions I built to demo development topics over the previous week.

Here’s my PowerShell script. It saves me a great deal of time, I hope it save you some too!

The Script

function Uninstall-AllSPSolutions {
    param (
        [switch] $Local,
        [switch] $Confirm
    ) 

  Start-SPAssignment -Global;
  foreach($solution in (Get-SPSolution | Where-Object { $_.Deployed })) {
    write-host "Uninstalling Solution " $solution.Name;
    if($solution.DeployedWebApplications.Count -gt 0) {
      Uninstall-SPSolution $solution –AllWebApplications -Local:$Local -Confirm:$Confirm;
    } else {
      Uninstall-SPSolution $solution -Local:$Local -Confirm:$Confirm;
    }
    do {
      Start-Sleep 5;
      $solution = Get-SPSolution $solution;
    } while($solution.JobExists -and $solution.Deployed) 
  } 
  Stop-SPAssignment -Global;
}

function Remove-AllSPSolutions {
    param (
        [switch] $Confirm
    ) 
    Get-SPSolution | Where-Object { !$_.Deployed } | Remove-SPSolution -Confirm:$Confirm
}

Usage

If you’re saving the script to a file, say “Remove-AllSPSolutions.ps1” then remember to load the script before invoking it with:

. .\Remove-AllSPSolutions.ps1

You can uninstall all deployed solutions with the following command:

Uninstall-AllSPSolutions -Confirm

And then remove them with:

Remove-AllSPSolutions -Confirm