ASP.net;sharepoint
c# moss 程序人生
 提供wsp部署的参数:$wspnames:路径下的所有wsp文件名用逗号隔开,如“sumhtestwsp.wsp,sumhtestwsp123.wsp,sumhtestwsp456.wsp,sumhtestwsp789.wsp”

 

方法:

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"

posted on 2011-07-26 16:26  sumh  阅读(306)  评论(0编辑  收藏  举报