Last active
January 4, 2024 15:28
-
-
Save dfbaskin/8a2fdb01cb7a922e4e14c82d65cb478a to your computer and use it in GitHub Desktop.
Set up Visual Studio command line shell in PowerShell (v7+)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
param ( | |
[string] $name = 'Visual Studio Enterprise 2022' | |
) | |
$VSInstance = Get-CimInstance MSFT_VSInstance -Namespace root/cimv2/vs | | |
Where-Object { $_.ElementName -eq $name } | |
if (-not $VSInstance) { | |
throw "Could not find Visual Studio installation details." | |
} | |
$devShell = Join-Path $VSInstance.InstallLocation 'Common7\Tools\Microsoft.VisualStudio.DevShell.dll' -Resolve | |
$vsID = $VSInstance.IdentifyingNumber | |
Push-Location | |
Import-Module $devShell | |
Enter-VsDevShell $vsID | |
Pop-Location |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment