Search notes:

PowerShell: the preference variable $MaximumVariableCount

The preference variable $maximumVariableCount specifies how many user-defined variables are allowed in a session.
The default value is 4096.
The following snippet is likely to hit the error message Cannot create variable var_4049 because variable capacity 4096 is exceeded for this scope:
for ($i = 0; $i -lt $maximumVariableCount; $i++) {
   invoke-expression "`$var_$i = $i"
}

See also

Preference variables

Index