Just for fun I ran that code:
for ($i = 0; $i -le 9999; ++$i) { New-Variable $i $i -ErrorAction Stop }
PowerShell 5.1 returned:
New-Variable : Cannot create variable 4073 because variable capacity 4096 is exceeded for this scope.
But in PowerShell 7.0.3 I changed for for creating 1 milliard variables.
And I'm tired of waiting.. and canceled it when pwsh ate 7 Gb of my RAM...
$i was 18,401,068 at that moment!
It meant that PS 7.0.3 has no limit for variables count or it is very high.
So why is there limit for 4096 variables count in PS 5.1?