Power Shellを使用して複数のファームソリューションを追加する(デプロイされません)
-
09-12-2019 - |
質問
私はあるSharePoint 2010ファームから別のSharePoint 2010ファームに約200のWSPSを移行しようとしています。私はすでにWSPファイルを新しいファームのフォルダにコピーしました。
私はフォルダのパスを入力として受け取り、フォルダ内のすべてのWSPをファームに追加できるPowerShellスクリプトが必要です。展開したくないと、農場に追加したくない。
例入力: -
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ファームソリューション抽出器を使用して、1つのサーバーと上記のスクリプトからWSPを作成してファームに追加します。WSPとパラメータの種類がたくさんあるため、install-solutionスクリプトはより多くの機能です。
所属していません sharepoint.stackexchange