Automatic Visual Studio Nuget consolidatation
You can use Select-Object instead of casting to pscustomobjects. For instance this:

foreach { [pscustomobject]@{ packagename=$_.packagename; VG=$_.VG; versions=$_.versions; versionCount= $_.versions.Count; versionMAX=$_.versionMAX }}


becomes this, which is somewhat shorter and less noisy:

select packagename VG versions @{Name="versionCount"; Exp={$_.versions.Count}} versionMAX


Notice the calculated property for versionCount.

Regarding the single line of code, I think you could have multiple statements separated by semicolons. You would work on the code as multiple lines in your text editor, and then join them together before pasting into VS.

Write-Output hello; Write-Output world