Batch WSP package deployment using powershell

Source: Internet
Author: User

Parameters for WSP deployment are provided:

$ Wsppath: Path of the WSP file, for example, "C :\"

$ Wspnames: All WSP file names in the path are separated by commas, for example, "sumhtestwsp. WSP, sumhtestwsp123.wsp, sumhtestwsp456.wsp, sumhtestwsp789.wsp"

$ Allwebapp: whether to deploy globally, for example, "$ true". "True" indicates to deploy globally. $ webid: $ allwebapp is set to "$ false". Enter the specified application.ProgramGuid

Method:

Function deploywsp ([String] $ wsppath, [String] $ wspnames, [bool] $ allwebapp, [guid] $ webid)

{

$ Pssnapinlogs poin = Get-pssnapin Microsoft. Sharepoint. powershell-erroraction silentlycontinue

If ($ pssnapin1_poin-EQ $ null)

{

Add-pssnapin Microsoft. Sharepoint. powershell;

}

Foreach ($ wspname in $ wspnames. Split (','))

{

$ Gspsolution = Get-spsolution-identity $ wspname-erroraction silentlycontinue

If ($ gspsolution-EQ $ null)

{

Add-spsolution-literalpath $ wsppath. insert ($ wsppath. length, $ wspname)

}

If ($ allwebapp)

{

If (! $ Gspsolution. Deployed)

{

Install-spsolution-identity $ wspname-gacdeployment-allwebapplications

}

}

Else

{

If (! $ Gspsolution. Deployed)

{

Install-spsolution-identity $ wspname-gacdeployment-webapplication $ webid

}

}

}

}

For example

deploywsp-wsppath "C: \"-wspnames "sumhtestwsp. WSP, sumhtestwsp123.wsp, sumhtestwsp456.wsp "-allwebapp $ true

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.