-
Notifications
You must be signed in to change notification settings - Fork 43
Inventory of Instances
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.
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
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
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') }
Copyright (C) Microsoft Corporation. All rights reserved. Licensed under the MIT license. See LICENSE.txt in the project root for license information.