diff --git a/src/PSADTree/PSADTreeCmdletBase.cs b/src/PSADTree/PSADTreeCmdletBase.cs index ae66a8e..2c8b12e 100644 --- a/src/PSADTree/PSADTreeCmdletBase.cs +++ b/src/PSADTree/PSADTreeCmdletBase.cs @@ -98,17 +98,15 @@ protected override void BeginProcessing() protected void Push(GroupPrincipal? groupPrincipal, TreeGroup treeGroup) { - if (Recursive.IsPresent || treeGroup.Depth <= Depth) + if (!Recursive.IsPresent && treeGroup.Depth >= Depth && !_truncateWritten) { - _stack.Push((groupPrincipal, treeGroup)); + this.WriteWarning($"Result is truncated as enumeration has exceeded the set depth of {Depth}."); + _truncateWritten = true; } - else + + if (Recursive.IsPresent || treeGroup.Depth <= Depth) { - if (!_truncateWritten) - { - this.WriteWarning($"Result is truncated as enumeration has exceeded the set depth of {Depth}."); - _truncateWritten = true; - } + _stack.Push((groupPrincipal, treeGroup)); } }