sharepoint - 使用PowerShell自动部署解决方案

标签 sharepoint powershell

我有一个文件夹,其中包含要添加和安装的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/

相关文章:

sharepoint - 什么时候 SPFile.Properties != 到 SPFile.Item.Properties 在 SharePoint 中?

c# - 代码访问安全和 Sharepoint WebParts

powershell - 使用Powershell更改SSRS报告的数据源

sharepoint - 发生意外的错误

sharepoint - 在Sharepoint Server 2010中以编程方式创建文档集

azure - 术语 'Get-AzADServicePrincipal' 未被识别为 cmdlet、函数的名称

security - PowerShell 的 ConvertFrom-SecureString -key 有多安全

windows - 使用 Powershell 命令进行文件计数

powershell - 如何修复/加速 powershell 脚本?

powershell - Azure 函数中的 PNP PowerShell 在某个时间间隔内快速触发时失败