powershell - Invoke-ASCmd 在 PowerShell 中返回错误/警告
问题描述
在我的部署管道中运行 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 的输出文件并确定是否存在警告或错误。在我的天蓝色管道中向控制台返回警告消息是理想的。
示例警告消息:
<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
}
解决方案
推荐阅读
- r - R中混合数据采样的回归
- firebase - 有没有办法在颤振应用程序中使用firebase查找具有相同子名的孩子的总数?
- php - 如何测试 Laravel 中 JSON 文件中存在的嵌套 JSON 数据?
- powershell - 在 For Each 语句中过滤 Powershell 结果
- symfony - 如何在 Shopware 6 中使用多个队列工作者?
- android - 如何为 Android 应用程序中的多种登录方式构建活动/片段
- python - 熊猫:回顾过去
- python - MongoDB对属性的最接近匹配给出属性的一部分
- javascript - 如何使用重叠 div 获取当前悬停位置?
- c# - 为什么在将值传递给另一个 C# 表单到文本框字段时 SELECT 不选择 TESTID?