Powershell magic in WSP deployment


Follow the steps to achieve this :
  1. Open the Notepad,

    Write the code below,

    #pass the source path "$ source",e.g d:\wspfolder\ 
    $source ="D:\wspfolder\"
    $files = Get-ChildItem $source | where {$_.extension -eq ".wsp"}
    foreach($my_file in Get-ChildItem $files){Add-SPSolution -LiteralPath $my_file.FullName}
    foreach($my_file in Get-ChildItem $files){Install-SPSolution -Identity $my_file.Name -AllWebApplications -GACDeployment}

  2. Save the file  with some name and having extension ".ps1"(e.g  installer.ps1).

  3. Next task to create Batch file.Open the Notepad again,write the following code,

    Powershell.exe -Command Set-ExecutionPolicy "Bypass"
    Powershell.exe -Command "& {d:\wspfolder\Installer.ps1}"
    Pause

  4. Save As file with name "install.bat".

  5. Now its done. Hope you like this blog and will save your time too.