Summary
Get-AzRetirementRecommendation collects all recommendations into an in-memory List[object] and returns them as an array in the end block, preventing pipeline streaming.
Impact
In large tenants with many subscriptions and recommendations, this delays first output until all subscriptions have been queried and increases peak memory usage.
Location
Public/Get-AzRetirementRecommendation.ps1
$allRecommendations accumulator: line 41
- Return in
end block: line 351
Suggested fix
Emit each PSCustomObject directly in the process block instead of accumulating. If callers need array output, they can collect with @(Get-AzRetirementRecommendation).
This is a behavioral change (streaming vs. buffered), so it could be offered as an opt-in -Stream switch to maintain backward compatibility.
Summary
Get-AzRetirementRecommendationcollects all recommendations into an in-memoryList[object]and returns them as an array in theendblock, preventing pipeline streaming.Impact
In large tenants with many subscriptions and recommendations, this delays first output until all subscriptions have been queried and increases peak memory usage.
Location
Public/Get-AzRetirementRecommendation.ps1$allRecommendationsaccumulator: line 41endblock: line 351Suggested fix
Emit each
PSCustomObjectdirectly in theprocessblock instead of accumulating. If callers need array output, they can collect with@(Get-AzRetirementRecommendation).This is a behavioral change (streaming vs. buffered), so it could be offered as an opt-in
-Streamswitch to maintain backward compatibility.