Adding all solutions from one folder into solution store

So, now that SP2010 is using Powershell 2.0 I need to have a reminder of how to do my daily work with it.

Here is a little script on deployment (actually just the adding, I like using the administration panel when I work on my dev machine, which is my last step, while deving of course I use Studio to do the deployment)

// get the current location
$path = (get-location).path
// get all wsp files
$files = get-childitem | where {$_.extension -eq ".wsp"}
// foreach wsp file in the current folder
foreach($file in $files)
    // get the absolute path (needed for the add-spsolution command)
    $solpath = $path + '\' + $file
    // output the current action
    write-host "Adding" $solpath "to farm solution store!"
    // add the solution to the solution store
    add-spsolution "$solpath"

You could also – prior to adding the solution – check to see if the solution is already (deployed or added) and then (retract and) remove it.
For deployment of the solution you need to have a sleep command ready, because adding is a job, that needs to finish and then use the deploy-spsolution with either the -allwebapplications or the webapp parameter.
Something like this.

If you can’t use the SharePoint Management Shell, here is the snap-in command for the Windows Powershell:

Add-PSSnapin Microsoft.SharePoint.PowerShell

Took this from here.