WVD Management Using Visual Studio Code Instead of PowerShell ISE

0
WVD Management Using Visual Studio Code Instead of PowerShell ISE

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!

WVD V2 Experience

If you don’t want to install Visual Studio code to manage WVD v2, you can use the latest version of PowerShell Core.

PowerShell Core 7 (Preview)
PowerShell Core 7 (Preview)

Install Visual Studio Code

  • Download the Visual Studio Code for Windows 10 from Microsoft (Direct 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.
WVD Management Using Visual Studio Code Instead of PowerShell ISE
WVD Management Using Visual Studio Code Instead of PowerShell ISE
  • Select the installation folder
    • C:\Users\Anoop C Nair\AppData\Local\Programs\Microsoft VS Code
  • Click on next button to continue
WVD Management Using Visual Studio Code Instead of PowerShell ISE
WVD Management Using Visual Studio Code Instead of PowerShell ISE
  • 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
WVD Management Using Visual Studio Code Instead of PowerShell ISE 1
  • 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
WVD Management Using Visual Studio Code Instead of PowerShell ISE 2
  • Installing the Microsoft Visual Studio Code (User).
WVD Management Using Visual Studio Code Instead of PowerShell ISE 3
  • Installation of Microsoft Visual studio code completed.
  • Click on FINISH to launch the visual studio code app.
WVD Management Using Visual Studio Code Instead of PowerShell ISE
WVD Management Using Visual Studio Code Instead of PowerShell ISE

Configure PowerShell

  1. Press Ctrl+P (Quick-Open) to launch the search option
  2. In Quick-Open, type ext install powershell and press Enter.
  3. Select the Powershell Extension for Visual Studio Code (PowerShell Scripts in Visual Studio code).
  4. Click on the Install button to continue.
WVD Management Using Visual Studio Code Instead of PowerShell ISE
WVD Management Using Visual Studio Code Instead of PowerShell ISE
  • Select PowerShell ISE as shown in the below screen capture.
WVD Management Using Visual Studio Code Instead of PowerShell ISE
WVD Management Using Visual Studio Code Instead of PowerShell ISE
FunctionISE BindingVS Code Binding
Interrupt and break debuggerCtrl+BF6
Execute current line/highlighted textF8F8
List available snippetsCtrl+JCtrl+Alt+J
ISE Key Binding in VC Code

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.
WVD V2 Management Using Visual Studio Code Instead of PowerShell ISE
WVD V2 Management Using Visual Studio Code Instead of PowerShell ISE
  • 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
WVD V2 Management Using Visual Studio Code Instead of PowerShell ISE
WVD V2 Management Using Visual Studio Code Instead of PowerShell ISE

Resources

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.