我有一个文件夹,其中包含要添加和安装的SharePoint应用程序的几种解决方案。我想遍历文件夹中的元素,然后使用Add-SPSolution。之后,我想在使用Install-SPSolution之前检查解决方案是否已完成部署。这是我目前正在处理的代码段:
# Get the location of the folder you are currently in
$dir = $(gl)
# Create a list with the .wsp solutions
$list = Get-ChildItem $dir | where {$_.extension -eq ".wsp"}
Write-Host 'DEPLOYING SOLUTIONS...'
foreach($my_file in Get-ChildItem $list){Add-SPSolution -LiteralPath $my_file.FullName}
Write-Host 'SLEEP FOR 30 SECONDS'
Start-Sleep -s 30
Write-Host 'INSTALLING SOLUTIONS...'
foreach($my_file in Get-ChildItem $list){Install-SPSolution -Identity $my_file.Name -AllWebApplications -GACDeployment}
有没有一种方法可以检查部署是否完成,并且可以开始安装解决方案了?
最佳答案
您需要循环检查SPSolution.Deployed property值-基本解决方案如下所示:
do { Start-Sleep 2 } while (!((Get-SPSolution $name).Deployed))
Deploying SharePoint 2010 Solution Packages Using PowerShell文章包含更多详细信息,并且this comment讨论了潜在的警告。
关于sharepoint - 使用PowerShell自动部署解决方案,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7397585/