Skip to content

Inventory of Instances

Heath Stewart edited this page Sep 1, 2017 · 4 revisions

The Get-VSSetupInstance cmdlets is the primary way to discover installed instances. By default, only launchable instances - product instances that might have generated some install warnings but otherwise should work - are enumerated.

General queries

Get-VSSetupInstance

You can also enumerate all instances whether they are pending a system reboot or haven't installed correctly and may require a repair.

Get-VSSetupInstance -All

Workload and component queries

You can neatly format a table of what workloads and components are installed for each instance.

Get-VSSetupInstance -All -Prerelease | Select-Object -Expand packages @{l='Name'; e={if ($nn = $_.properties['Nickname']) { '{0} ({1})' -f $_.DisplayName, $nn} else { $_.DisplayName}}} | Where-Object type -in 'workload', 'component' | Sort-Object Name, @{e='Type'; desc=$true}, Id | Format-Table -Group Name -Property Type, Id

State queries

The State property consist of additive flags. As the product is installed, new state may be represented. So if there is no reboot pending, the state would include NoRebootPending. So rather than checking if a reboot is required, you need to check if a reboot is not required.

Get-VSSetupInstance | Where-Object { -not ($_.State -band 'NoRebootRequired') }

You can also check which instances have errors and may require a repair (also evident in the Visual Studio Installer).

Get-VSSetupInstance | Where-Object { -not ($_.State -band 'NoErrors') }