You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何用PowerShell检测Office Online Server中文档是否渲染成功?

通过SharePoint Web API选取并渲染文档的PowerShell实现及问题

我可以通过Web API调用从SharePoint文档库中选取指定的文档,并将其发送进行渲染。

function Get-SpOosDocumentResponse {
  [CmdletBinding()]
  param (
    [string]$SiteCollectionUrl,
    [string]$DocLibraryName,
    [string]$FolderPath = '.',
    [string]$DocumentName
  )

  $RestApiUrl = "$SiteCollectionUrl/_api/web/GetFolderByServerRelativeUrl" +
    "('$DocLibraryName/$FolderPath')/Files"

  $ShpFolderResponse = Invoke-RestMethod `
    -Uri $RestApiUrl `
    -UseDefaultCredentials `
    -Method Get `
    -Headers @{
      "Accept" = "application/json;odata=verbose"
    }

  $Files = $ShpFolderResponse.d.results

  $DocId = $Files | where Name -eq $DocumentName | select UniqueId

  if (!$DocId) {
    Write-Error "$DocumentName not found." -ErrorAction Stop
  }

  $WopiUrl = "$SiteCollectionUrl/_layouts/WopiFrame2.aspx" +
    "?sourcedoc={$DocId}&action=view"

  $WopiResponse = Invoke-WebRequest -Uri $WopiUrl -UseDefaultCredentials

  return $WopiResponse

}

但由于文档渲染是在浏览器中通过JavaScript完成的,我无法使用PowerShell分析响应来判断渲染是否成功。此外,我甚至无法通过客户端访问检测WOPI绑定是否损坏,因为没有可捕获的错误信息。

内容的提问来源于stack exchange,提问作者Dennis

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.17 02:37:06