方法:
function RemoveWSP([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 -ErrorAction silentlycontinue
if($gspsolution -ne $null)
{
if(!$gspsolution.Deployed)
{
Remove-SPSolution -Identity $wspname
}
}
}
}
例如:
RemoveWSP -wspnames "sumhtestwsp.wsp,sumhtestwsp123.wsp,sumhtestwsp456.wsp"