public/Get-SsasProcessingMessages.ps1
function Get-SsasProcessingMessages { <# .SYNOPSIS Examines the XML returned by the Invoke-AsCmd function to find errors. Write an error message if error message found. #> [CmdletBinding()] param ( [String] [Parameter(Mandatory = $true)] [ValidateNotNullOrEmpty()] $ASCmdReturnString ) $returnXml = New-Object -TypeName System.Xml.XmlDocument; $returnXml.LoadXml($ASCmdReturnString); [System.Xml.XmlNamespaceManager] $nsmgr = $returnXml.NameTable; $nsmgr.AddNamespace('xmlAnalysis', 'urn:schemas-microsoft-com:xml-analysis'); $nsmgr.AddNamespace('rootNS', 'urn:schemas-microsoft-com:xml-analysis:empty'); $nsmgr.AddNamespace('exceptionNS', 'urn:schemas-microsoft-com:xml-analysis:exception'); $rows = $returnXML.SelectNodes("//xmlAnalysis:return/rootNS:root/exceptionNS:Messages/exceptionNS:Error", $nsmgr) ; foreach ($row in $rows) { throw $row.Description; } } |