AnsweredAssumed Answered

Using PowerShell to process rollup analysis errors

Question asked by arosenthal on Apr 22, 2016
Latest reply on Apr 22, 2016 by arosenthal

I am trying to convert a C# application I wrote to process analysis errors to a PowerShell script, but seem to be running into a roadblock. It appears that loading the AFSDK assembly in PowerShell does not load the analytics assemblies like Visual Studio does.


The following is a snippet of the C# application I have written:


AFAnalysisRuleConfiguration configuration = analysis.AnalysisRule.GetConfiguration();
if (configuration.HasExceptions)
    // Flag if error message is "Failed to resolve required input 'SearchCriteria'
    bool searchFail = false;

    ICollection<AFAnalysisException> exceptionGroups = configuration.ConfigurationExceptions;
    foreach (AFAnalysisException error in exceptionGroups)
        if (error.Severity == AFAnalysisErrorSeverity.Error && error.Message == "Failed to resolve required input 'SearchCriteria'")
            searchFail = true;


and here is how I have converted it into PowerShell:


$analysisRule = $analysis.AnalysisRule

$configuration = $analysisRule.GetConfiguration()

if ($configuration.HasExceptions -eq $True) {

$searchFail = $False

$exceptionGroups = $configuration.ConfigurationExceptions

foreach ($error in $exceptionGroups) {


if (($error.Severity -eq [OSIsoft.AF.Analysis.AFAnalysisErrorSeverity]::Error) -And ($error.Message -eq "Failed to resolve required input 'SearchCriteria'")) {

$searchFail = $True





The problem is that in the PowerShell script, rollup analyses always have the following value in $error.Message:


Fail to load analysis rule (Analysis Rule: 'Rollup', Path: '<AssetPathHere>[<AnalysisNameHere>]\AnalysisRule'): Failed to load 'Rollup' PlugIn: The PlugIn type 'OSIsoft.AF.Analysis.AnalysisRule.Rollup' was not found.

In the C# application, however, the error message is correct. Any idea why this is occurring?