我正在尝试从一个SharePoint 2010农场迁移到另一个200 WSP。我已经将WSP文件复制到新农场中的文件夹。

我需要一个PowerShell脚本,可以将文件夹的路径作为输入,并将位于文件夹中的所有WSP添加到农场。我不想部署,而不是将它们添加到农场。

示例输入: -

c:\ exportedwsp

有帮助吗?

解决方案

只提供WSP所在文件夹的路径,并且该功能将在解决方案存储中添加所有WSP。

Remove-PSSnapin Microsoft.SharePoint.PowerShell -erroraction SilentlyContinue
Add-PSSnapin Microsoft.SharePoint.PowerShell -erroraction SilentlyContinue
function WaitForInsallation([string] $Name)
{
        Write-Host -NoNewline "Waiting for deployment job to complete" $Name "."
        $wspSol = get-SpSolution $Name
        while($wspSol.JobExists)
        {
            sleep 2
            Write-Host -NoNewline "."
            $wspSol = get-SpSolution $Name
        }
        Write-Host "job ended" -ForegroundColor green
}
Function Deploy-SPSolution ($WspFolderPath)
{
    $wspFiles = get-childitem $WspFolderPath | where {$_.Name -like "*.wsp"}

    ForEach($file in $wspFiles)
    {
        $wsp = Get-SPSolution | Where{$_.Name -eq $file.Name}
        if($wsp -eq $null)
        {
            write-host "Adding solution"
            Add-SPSolution -LiteralPath ($WspFolderPath + "\" + $file.Name)
        }
        else
        {
            write-host "solution already exists"

        }

    }
}
try
{
        Deploy-SPSolution "C:\EXPORTEDWSP"
}
catch
{
    write-host $_.exception

}
.

其他提示

如果只有在干净的农场上有一个WSP的文件夹,则可以缩短脚本:

$names = get-childitem F:\SPProdSolutionsExtract
foreach ($solution in $names) {Add-SPSolution -LiteralPath ("F:\SPProdSolutionsExtract\" + $solution.Name) }
.

我使用SharePoint农场解决方案提取器从一个服务器和上面脚本获取WSP,将它们添加到农场。安装解决方案脚本是更多的工作,因为有这么多类型的WSP和参数。

许可以下: CC-BY-SA归因
scroll top