diff --git a/applications/pskql/PsKqlCmdlet.cs b/applications/pskql/PsKqlCmdlet.cs index af651d1f..b5aa53d5 100644 --- a/applications/pskql/PsKqlCmdlet.cs +++ b/applications/pskql/PsKqlCmdlet.cs @@ -59,6 +59,10 @@ protected override void EndProcessing() //index and pad with nulls where necessary foreach (var p in item.Properties) { + if (p is PSScriptProperty scr) + { + + } if (badProperties.Contains(p.Name)) continue; //it's important we check the property type _before_ attempting to access the Value @@ -153,12 +157,29 @@ private void AddValue(string columnName, string typeName, object? value, int row //special-casing for properties of type "object" which we turn into strings for the purpose of querying if (typeName == TypeNameHelper.TypeName()) { - typeName = TypeNameHelper.TypeName(); - value = value?.ToString() ?? string.Empty; - } - + if (value != null) + { + WriteDebug($"property '{columnName}' is object so trying to derive type from value"); + typeName = value.GetType().ToString(); + WriteDebug($"prop {columnName} typeof '{value}' is {typeName}"); + if (value is PSObject ps) + { + WriteDebug($"property '{columnName}' is PSObject so trying to derive type from BaseObject"); + typeName = ps.BaseObject.GetType().ToString(); + WriteDebug($"prop {columnName} baseobj typeof '{ps.BaseObject}' is {typeName}"); + value = ps.BaseObject; + } + } + else + { + typeName = TypeNameHelper.TypeName(); + value = value?.ToString() ?? string.Empty; + } + + } + WriteDebug($"Getting builder for {columnName}"); var colBuilder = GetOrCreateBuilder(columnName, typeName); colBuilder.AddAt(value, rowIndex); } -} \ No newline at end of file +}