转:http://www.xuebuyuan.com/168334.html
提供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)
{
#1.收回解决方案
if($gspsolution.Deployed)
{
Uninstall-SPSolution -AllWebApplications -Identity $wspname
}
#2.删除解决方案管理区的解决方案
Remove-SPSolution -Identity $wspname -Confirm:$false
}
}
}
例如:
recoverWSP -wspnames “sumhtestwsp.wsp,sumhtestwsp123.wsp,sumhtestwsp456.wsp”