In this post, let’s learn how to start WVD Management Using Visual Studio Code Instead of PowerShell ISE. Well, Windows Virtual Desktop (WVD v2) supports only PowerShell core 7.0 or later. I have been extensively using PowerShell ISE (Yes!). But, I still love GUI and I don’t like coding 🙂
Note! – This post mostly applies to the Windows Virtual Desktop spring 2020 release (a.k.a WVD v2). This Spring 2020 update uses the Azure Resource Manager (ARM) Windows Virtual Desktop objects.
Windows Virtual Desktop cmdlets (Az.DesktopVirtualization) currently only work with PowerShell Core. So, there is PowerShell ISE support! We need to find out some other way to get PowerShell ISE experience.
Now, don’t ask me why do we need PowerShell commands with WVD new portal Experience? Well, one example is personal desktop assignments in WVD v2 and this is only possible using PowerShell Core!
If you don’t want to install Visual Studio code to manage WVD v2, you can use the latest version of PowerShell Core.
Install Visual Studio Code
- Download the Visual Studio Code for Windows 10 from Microsoft (Direct download).
- Alternate – https://code.visualstudio.com/download
- Double click on the VSCodeUserSetup-x64-1.46.0.exe to start the installation.
- Accept the license terms and click on the NEXT button.
- Select the installation folder
- C:\Users\Anoop C Nair\AppData\Local\Programs\Microsoft VS Code
- Click on next button to continue
- Setup will create a shortcut folder in the start menu folder with the name – Visual Studio Code.
- You can an option to opt-out from creating a start menu folder.
- Click on Next to continue
- Select the additional options in this window. I have added following options.
- Add “Open with Code” action to Windows explorer file context menu
- Add “Open with Code” action to Windows Explorer directory context menu
- Register Code as an editor for supported file types
- Add to PATH (requires shell restart)
- Click on Next to continue
- Installing the Microsoft Visual Studio Code (User).
- Installation of Microsoft Visual studio code completed.
- Click on FINISH to launch the visual studio code app.
- Press Ctrl+P (Quick-Open) to launch the search option
- In Quick-Open, type
ext install powershelland press Enter.
- Select the Powershell Extension for Visual Studio Code (PowerShell Scripts in Visual Studio code).
- Click on the Install button to continue.
- Select PowerShell ISE as shown in the below screen capture.
|Function||ISE Binding||VS Code Binding|
|Interrupt and break debugger||Ctrl+B||F6|
|Execute current line/highlighted text||F8||F8|
|List available snippets||Ctrl+J||Ctrl+Alt+J|
Results – WVD Management Using Visual Studio Code
I can get very similar experience as of PowerShell ISE using VS code (Visual Studio Code). More details below:
- If you already imported the PowerShell modules on Windows 10 device, then you don’t have to import those modules again.
- You can have the Terminal window on the left side.
- You can use the existing PS1 files using visual studio code now.
- The following are the sample PowerShell core commands you can try in VS code to management WVD V2.
>Get-AzWvdSessionHost -HostPoolName $Hostpoolname -ResourceGroupName $ResourcegroupName | Format-List >Get-AzWvdHostPool -ResourceGroupName $ResourcegroupName | Format-List