Managing Two Azure VMs from One PowerShell Session

45 minutes
  • 3 Learning Objectives

About this Hands-on Lab

In this hands-on lab, you are tasked with finding system information from multiple VMs using PowerShell. Instead of logging into each server, it’s much easier to perform PowerShell commands from a single terminal. Using the `Enter-AzVM` command, you will be able to access the Azure VM from a PowerShell session and perform all the necessary commands, just as if you were logged into the machine.

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

Open Cloud Shell and Navigate to Your Resource Group
  1. Open Cloud Shell and open the PowerShell prompt.
  2. Change directory into the resource group for this hands-on lab.
  3. Run Get-AzVM to get a list of all VMs.
Enable PowerShell Remoting for Both VMs
  1. Enable PowerShell remoting for the Windows VM:

    Enable-AzVMPSRemoting -Name 'winVM' -Protocol https -OsType Windows
  2. Enable PowerShell remoting for the Linux VM:

    Enable-AzVMPSRemoting -Name 'linvm' -Protocol ssh -OsType Linux
Enter the VM and Get the Memory Utilization
  1. Access the Windows VM:

    Enter-AzVM -Name 'winVM' -Credential (Get-Credential)
  2. Access the Linux VM:

    Enter-AzVM -Name 'linVM' -Credential (Get-Credential)
  3. Once logged in, perform the following command on a Windows VM:

    systeminfo | findstr "Virtual Memory"
  4. Once logged in, perform the following command on a Linux VM:

    grep MemTotal /proc/meminfo

Additional Resources

You are tasked with finding the system information from each VM. More specifically, you will need to get the memory utilization. In order to do this, you must first set up PowerShell Remoting on each VM.

In order to complete this hands-on lab, perform the following:

  • Open the Azure Cloud Shell and open the PowerShell prompt. Make sure to use the same location as your lab provided resource group.
  • Enable a remote PowerShell session over SSH protocol for Linux.
  • Enable a remote PowerShell session over https (winrm) protocol for Windows.
  • Access the VM using the Enter-AzVM command.
  • Perform the command to obtain the system memory utilization.

What are Hands-on Labs

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Sign In
Welcome Back!

Psst…this one if you’ve been moved to ACG!

Get Started
Who’s going to be learning?