How to Automate SharePoint 2010/2013/2016 WSP Backup and deployment through Power Shell

///How to Automate SharePoint 2010/2013/2016 WSP Backup and deployment through Power Shell
How to Automate SharePoint 2010/2013/2016 WSP Backup and deployment through Power Shell2018-10-16T12:52:36+00:00

Front Page Forums SharePoint SharePoint Deployment. How to Automate SharePoint 2010/2013/2016 WSP Backup and deployment through Power Shell

Viewing 1 post (of 1 total)
  • Author
    Posts
  • ScientistZ
    Keymaster
    Post count: 39

    How to Automate SharePoint 2010/2013/2016 WSP Backup and deployment through Power Shell

    Solution:

    Below solution, have high lighted the need to change values, since we have hard coded the parameter values, because If you have cascaded log running deployment some times, the variable become unavailable and your whole deployment fails or may occur some serious issues with the deployment, so it is best to use hard codded values to avoid mistakes and deployment errors.

    Run Power Shell as administrator.

    Just change the highlighted values and copy paste the code.

    Add-PSSnapin Microsoft.SharePoint.PowerShell

    #BackUP WSP Only 

    $farm = Get-SPFarm
    $file = $farm.Solutions.Item(“MyWSP.wsp“).SolutionFile
    $file.SaveAs(“D:\backup\26.June.18\4.50\MyWSP.wsp“)

    #Uninstall
    Uninstall-SPSolution -Identity “MyWSP.wsp” -WebApplication “http://mySite.com” -CompatibilityLevel “All” -confirm:$false
    Do{
    $wspID = Get-SPSolution -Identity “MyWSP.wsp
    if($wspID.JobExists -eq $false){
    Write-Host ‘Deployed: ‘ $wspID.Deployed ‘JobStatus: ‘ $wspID.JobExists ‘************Uninstalled Done*************’;

    #Remove, ADD, Install
    Remove-SPSolution -Identity “MyWSP.wsp” -Force -confirm:$false
    Add-SPSolution –LiteralPath “D:\SECB\26.June.18\4.51\MyWSP.wsp” -confirm:$false
    Install-SPSolution –Identity “MyWSP.wsp” –WebApplication “http://mySite.com” –GACDeployment -FullTrustBinDeployment –Force -confirm:$false

    //Check Final Deployment Status

    Do{
    $wspID = Get-SPSolution -Identity “MyWSP.wsp
    if($wspID.Deployed -eq $true){
    Write-Host ‘************Done*************’;
    break;
    }
    else{
    Start-Sleep -s 10
    Write-Host ‘****Not Done. Still Deploying****’;

    }
    }while($true)
    #end

    break;
    }
    else{
    Start-Sleep -s 10
    Write-Host ‘****Still UnInstalling****’;

    }
    }while($true)

    Output:

     

    ****Still UnInstalling****

    *

    *
    Deployed: False JobStatus: False ************Uninstalled Done*************

    Name SolutionId Deployed
    —- ———- ——–
    secbv2.portal.commonusercon… 076f4882-ed1e-4c46-8d7a-a43b629fd942 False
    ****Not Done. Still Deploying****

    *

    ************Done*************

     

    you have full rights to modify this code as you like.

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.