在我的部署管道中运行PowerShell:
Write-Host "Invoking deployment script... This may take several minutes."
Invoke-ASCmd -Server:$SsasServer -InputFile $path\$bim.xmla | Out-File $path\$bim.xml
Write-Host "Please check $path\$bim.xml as this is output of this deployment"
我想获取Invoke-ASCmd的输出文件:$ bim.xml并确定是否存在警告或错误。将警告消息返回到我的azure管道中的控制台是理想的。
警告消息示例:
<return xmlns="urn:schemas-microsoft-com:xml-analysis"><root xmlns="urn:schemas-microsoft-com:xml-analysis:empty"><Exception xmlns="urn:schemas-microsoft-com:xml-analysis:exception" /><Messages xmlns="urn:schemas-microsoft-com:xml-analysis:exception"><Error ErrorCode="-1055784777" Description="The JSON DDL request failed with the following error: Failed to execute XMLA. Error returned: 'The column 'ProcessDateKey' in table 'Financial Measures' has invalid bindings specified.
'.." Source="Microsoft SQL Server 2016 Analysis Services Managed Code Module" HelpFile="" /></Messages></root></return>
我不确定这是否是正确处理此xml的正确方法。这是我的初稿:
[xml]$XmlDocument = Get-Content -Path $path\$bim.xml
if($XmlDocument.return.root.Messages.Error){
foreach ($errorMessage in $XmlDocument.return.root.Messages.Error ){
$message = $errorMessage.Description
Write-Error $message
}
exit 1
}