提供wsp部署的参数:$wspnames:路径下的所有wsp文件名用逗号隔开,如“sumhtestwsp.wsp,sumhtestwsp123.wsp,sumhtestwsp456.wsp,sumhtestwsp789.wsp”
方法:
function recoverWSP([string] $wspnames)
{
$PSSnapinSharePoin = Get-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction silentlycontinue
if( $PSSnapinSharePoin -eq $Null)
{
Add-PSSnapin Microsoft.SharePoint.PowerShell;
}
foreach($wspname in $wspnames.split(','))
{
$gspsolution = Get-SPSolution -Identity $wspname
if($gspsolution -ne $null)
{
if($gspsolution.Deployed)
{
Uninstall-SPSolution -AllWebApplications -Identity $wspname
}
}
}
}
例如:
recoverWSP -wspnames "sumhtestwsp.wsp,sumhtestwsp123.wsp,sumhtestwsp456.wsp"