The script you link to is broken (as of this writing):
Line 98:
Write-Debug No Retail versions of Visual Studio found, trying pre-release...
This line causes a syntax error, due to missing quoting; the correct syntax is:
Write-Debug 'No Retail versions of Visual Studio found, trying pre-release...'
Line 130:
$p = Start-Process -PassThru -Wait -FilePath $vsInstaller -ArgumentList ("modify --channelId $channelId --productId $productId $addWorkloads --quiet --includeRecommended" -split ' ')
The fact that this line fails indicates that at least one of the referenced variables - $channelId, $productId, $addWorkloads is unexpectedly $null.
As an aside:
That an error results from this is a manifestation of a Windows PowerShell bug (which has since been fixed in PowerShell (Core) 7+) - passing an empty array or $null or an array that has at least one $null element to the -ArgumentList property of Start-Process unexpectedly causes an error.
There is a separate Start-Process bug - still present as of PowerShell Core 7.2.2 - the workaround for which makes it better to pass all arguments as a single string with embedded "..." quoting (as needed) to -ArgumentList (see this answer):
$p = Start-Process -PassThru -Wait -FilePath $vsInstaller -ArgumentList "modify --channelId $channelId --productId $productId $addWorkloads --quiet --includeRecommended"