Thank you for reaching out.
The issue happens because PowerShell does not expand %ProgramFiles(x86)% that syntax works in CMD, not in PowerShell. When you pass it as-is, the installer sees an invalid path and truncates at the first space, creating C:\Program instead of the full folder.
To fix this:
Use PowerShell environment variable syntax: Replace %ProgramFiles(x86)% with $env:ProgramFiles(x86) so it expands correctly.
Quote the full path: Wrap the entire path in quotes so spaces are preserved when passed to Start-Process.
Example adjustment:
--installPath "$env:ProgramFiles(x86)\Microsoft Visual Studio\2019\BuildTools"
Compute the path first using Join-Path and store it in a variable, then pass that variable to --installPath. This avoids escaping issues.
Reference:
Use command-line parameters to install, update, and manage Visual Studio
Let me know if you need any further help with this. We'll be happy to assist.
If you find this helpful, please mark this as answered.