diff --git a/Rules/UseCompatibleCmdlets.cs b/Rules/UseCompatibleCmdlets.cs index 5079153d3..027567ba0 100644 --- a/Rules/UseCompatibleCmdlets.cs +++ b/Rules/UseCompatibleCmdlets.cs @@ -114,10 +114,9 @@ public IEnumerable AnalyzeScript(Ast ast, string fileName) IEnumerable functionDefinitionAsts = ast.FindAll(testAst => testAst is FunctionDefinitionAst, true); foreach (Ast functionDefinition in functionDefinitionAsts) { - string function = functionDefinition.GetType().GetProperty("Name").GetValue(functionDefinition).ToString(); - customCommands.Add(function); + FunctionDefinitionAst definition = (FunctionDefinitionAst)functionDefinition; + customCommands.Add(definition.Name); } - // If we have no cmdlets to check, we can exit from this rule. if (commandAsts.Count() == 0) {