如何用PowerShell检测Office Online Server中文档是否渲染成功?
我可以通过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
相关产品推荐
相关产品推荐

