In this post, let’s learn how to start AVD Management Using Visual Studio Code Instead of PowerShell ISE. Well, Azure Virtual Desktop (AVD) 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 AVD). 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 AVD’s new portal Experience? Well, one example is personal desktop assignments in AVD v2 and this is only possible using PowerShell Core!
If you don’t want to install Visual Studio code to manage AVD, you can use the latest version of PowerShell Core.
Install Visual Studio Code for AVD Management
Now, you will need to install Visual Studio Code for AVD management.
- 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 the Next button to continue
Setup will create a shortcut folder in the start menu folder with the name – Visual Studio Code.
You can have an option to opt-out of creating a start menu folder.
Click on Next to continue
Select the additional options in this window. I have added the following options.
Add the “Open with Code” action to the Windows explorer file context menu
Add the “Open with Code” action to the 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.
Configure PowerShell in Visual Studio Code for AVD
You will need to configure PowerShell in Visual Studio Code for AVD.
- 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.
- Run the Following Commands from the Terminal.
Install-Module -Name Microsoft.RDInfra.RDPowerShell Install-Module -Name Az.DesktopVirtualization -RequiredVersion 2.1.0 Import-Module -Name Microsoft.RDInfra.RDPowerShell
Run the following commands to select the appropriate subscription.
Connect-AzAccount Get-AzSubscription | Out-GridView -PassThru | Select-AzSubscription Update-AzWvdHostPool -ResourceGroupName WVD-Resource-Group -Name HostPool -StartVMOnConnect:$True
Select PowerShell ISE as shown in the below screen capture. (I can’t get this option from the latest version of VS Code?).
|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 – AVD Management Using Visual Studio Code Instead of PowerShell ISE
I can get a very similar experience as PowerShell ISE using VS code (Visual Studio Code). More details are 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 manage AVD V2.
>Get-AzWvdSessionHost -HostPoolName $Hostpoolname -ResourceGroupName $ResourcegroupName | Format-List >Get-AzWvdHostPool -ResourceGroupName $ResourcegroupName | Format-List
- Using Visual Studio Code as Your Default PowerShell Editor
- AVD Architecture Changes for v2| New Portal Admin Experience
Anoop is Microsoft MVP! He is a Solution Architect in enterprise client management with more than 20 years of experience (calculation done in 2021) in IT. He is Blogger, Speaker, and Local User Group HTMD Community leader. His main focus is on Device Management technologies like SCCM 2012, Current Branch, and Intune. He writes about ConfigMgr, Windows 11, Windows 10, Azure AD, Microsoft Intune, Windows 365, AVD, etc……………