This was encountered by a MS Partner team. When calling a cmdlet that outputs lots of objects, the SmartToString() helper throws the exception "InvalidOperationException: Collection was modified after the enumerator was instantiated" as the PSObject is modified before the conversion completes. There is already code to catch an ExtendedTypeSystemException and we could extend that for any exception and just return string.empty. Or alternatively, we could make a copy of the object but that would impact perf.
In the repro, it was explicitly going through the Format-List code, although Format-Table may also use this helper.
This was encountered by a MS Partner team. When calling a cmdlet that outputs lots of objects, the SmartToString() helper throws the exception "InvalidOperationException: Collection was modified after the enumerator was instantiated" as the PSObject is modified before the conversion completes. There is already code to catch an ExtendedTypeSystemException and we could extend that for any exception and just return string.empty. Or alternatively, we could make a copy of the object but that would impact perf.
In the repro, it was explicitly going through the
Format-Listcode, althoughFormat-Tablemay also use this helper.