vswhere could not detect VS2022
When I am running the below script in the PowerShell, vswhere is not able to detect Visual Studio 2022, Visual Studio is not updating.
$vswhere= "${Env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" $vswhereResult = & $vswhere -latest -product * if ($vswhereResult){ $vsLayoutPath = "\server\share\VSlayoutdirectory" & "$vsLayoutPath\vs_professional.exe" --quiet --update --wait --offline & "$vsLayoutPath\vs_professional.exe" update --installPath "vswhereResult" --noWeb --wait --quiet --norestart } else { Write-Host "Visual Studio not found" }
Do you have a preview installed? You need to pass -prerelease? To check if it's in a bad state and needs to be repaired, pass -all and check it's State property. By design, we show neither previews or incomplete instances in default results.
I don't have preview installed. I checked the state, it is not in bad state.
Please paste the output of vswhere -all -prerelease.
Also, you're missing a $ above. It should be:
$vswhere = "${Env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"
Note also that it doesn't exist if VS isn't installed, so you may want to pull it down via nuget e.g., nuget install vswhere -OutputDirectory "${env:TEMP}\vswhere" or something. Better for CIs.
Did you fix the line that should be:
$vswhere = "${Env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"
write-host "$vswhere"
And check that $vswhere contains what you think? As written in your OP, it's not correct so $vswhereResult wouldn't contain anything, or at error at best.
You also need to specify you want only the installationPath property:
vswhere.exe -latest -products * -property installationPath
You're passing a bunch of output to the installer so it's erring. You should be checking for errors as well in your script. vswhere appears to be working fine given your previous screenshot.