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