powershell 安装sharepoint webpart:这个脚本1)备份当前部署的webpart,2)删除以前的webpart,3)添加新的wsp,4)dep

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了powershell 安装sharepoint webpart:这个脚本1)备份当前部署的webpart,2)删除以前的webpart,3)添加新的wsp,4)dep相关的知识,希望对你有一定的参考价值。

$scriptPath = split-path -parent $MyInvocation.MyCommand.Definition

function InstallWebparts(){
    [CmdletBinding()]            
    Param(            
    [Parameter(Mandatory=$true)]  
    [string]$website,
    [Parameter(Mandatory=$true)]
    [string]$webpartName,
    [Parameter(Mandatory=$true)]
    [string]$webpartPath
    )
	
	#$sln = get-spsolution -identity $webpartName
	$sln = get-spsolution | where { $_.name -eq $webpartName }
	if ($sln -ne $null){		
	    echo "creando respaldo del archivo wsp actual de $webpartName"
		$bkpFolder =  "$($scriptPath)\bkp\" + [System.DateTime]::Now.ToString("yyyy-MM-dd")
		if ((test-path -path $bkpFolder) -eq $false){		
			New-Item -ItemType Directory -Path $bkpFolder > $null
		}
		$sln.SolutionFile.SaveAs("$bkpFolder\$webpartName")
		echo "respaldo creado en: $bkpFolder\$webpartName"		
	    echo "deinstalando el webpart existente $webpartName" 
		#Uninstall-SPSolution -Identity $webpartName -WebApplication $website -confirm:$false
		Uninstall-SPSolution -Identity $webpartName -AllWebApplications:$true -confirm:$false		
		while($sln.JobExists) { 
			echo " > desinstalacion en proceso..."
			start-sleep -s 10 
		}			
		
		Write-Host -f White "removiendo webpart"
		Remove-SPSolution -Identity $webpartName -confirm:$false
	}		
	
    Write-Host -f White "Agregando la solucion $webpartName al espacio de almacenamiento de sharepoint"
    Add-SPSolution -LiteralPath $webpartPath
    Write-Host -f White "solucion agregada"
    Write-Host -f White " "
    Write-Host -f White -nonewline "instalando la solucion "

	$sln =  get-spsolution -identity $webpartName
	if ($sln.ContainsWebApplicationResource){
		write-host -f yellow "modo: webapp"
		Install-SPSolution -Identity $webpartName -WebApplication $website -GacDeployment
	} else {
		write-host -f yellow "modo: farm"
	    Install-SPSolution -Identity $webpartName -GacDeployment
	}	
	
    $sln =  get-spsolution -identity $webpartName
    while($sln.JobExists) { 
      Write-Host " > instalacion en proceso..."
      start-sleep -s 10 
    }
    Write-Host -f Green "instalacion finalizada"
}

以上是关于powershell 安装sharepoint webpart:这个脚本1)备份当前部署的webpart,2)删除以前的webpart,3)添加新的wsp,4)dep的主要内容,如果未能解决你的问题,请参考以下文章

通过PowerShell卸载全部的SharePoint 2010 解决方式

使用PowerShell读取SharePoint里列表的内容

powershell 安装sharepoint webpart:这个脚本1)备份当前部署的webpart,2)删除以前的webpart,3)添加新的wsp,4)dep

Microsoft SharePoint Server 2016 部署文档

使用PowerShell部署sharepoint 2010计时器作业解决方案

powershell SharePoint Powershell在SharePoint模式下测试Analysis服务。这用于解决SharePoin中的Analysis服务问题