From http://social.technet.microsoft.com/Forums/en-US/9cc5b5c6-e728-4f48-af6c-00cf8be3d4ba/powershell-script-to-retract-remove-all-farm-solutions?forum=sharepointadminprevious