使用powershell部署WSP包

SharePoint解决方案部署流程

代码如下,先卸载,然后删除,然后添加,然后安装。

卸载之后会重启IIS,所以等待几秒钟,直到卸载完成。

添加snapin

$snapin = Get-PSSnapin | Where-Object {$_.Name -eq 'Microsoft.SharePoint.Powershell'} 
if ($snapin -eq $null)  
{    
    Write-Host "Loading SharePoint Powershell Snapin..."    
    Add-PSSnapin "Microsoft.SharePoint.Powershell" 
    Write-Host "SharePoint Powershell Snapin Loaded"   
}

 

部署代码

################
#Deploy Timejob#
write-host ""
write-host "--------------------------" -foregroundcolor green
write-host "Starting Install Solution!" -foregroundcolor green
$webApplication = "http://xxxx/"
$wspName= "TimeJob.wsp"
$sln = get-spsolution -identity $wspName
Uninstall-SPSolution -Identity $wspName -confirm:$false
while($sln.JobExists) {
    write-host "Uninstall in progress..." -foregroundcolor yellow
    start-sleep -s 5 
}
Remove-SPSolution -identity $wspName  -confirm:$false
write-host "Solution Removed!" -foregroundcolor green
$webpartPath="C:\Sharepoint\Deploy\WSP\" + $wspName 
Add-SPSolution $webpartPath 
Install-SPSolution -Identity $wspName -GACDeployment
write-host "Solution" $wspName "Installation Completed!" -foregroundcolor green
write-host "--------------------------" -foregroundcolor green

 

转载于:https://www.cnblogs.com/batter152/p/4900521.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值