How to Get Started with Azure PowerShell

Task automation has become a commonly used activity to optimize resource management in legacy, hybrid or cloud environments, and having a powerful set of command-line tools is essential for administrators.

Azure offers the flexibility companies require to choose the best command-line option to manage their subscriptions’ resources, including the Azure Portal, Azure Command-Line Interface (CLI) or Azure PowerShell. Read what Azure PowerShell is, steps to install it, and how it complements Parallels® Remote Application Server (RAS) PowerShell SDK to provide a complete and flexible command-line administration environment for hybrid or cloud scenarios.

What is Azure PowerShell?

In December 2018, Microsoft released the Azure PowerShell Az module (formerly AzureRM) for interaction with Azure. It works with PowerShell 5.1 on Windows, and PowerShell 6.x and higher on all platforms and it is also available in Azure Cloud Shell.

Azure PowerShell provides a full set of commands for Azure resource administration from the PowerShell command line. Administrators can use the cmdlets to perform complex tasks like provisioning virtual machines or managing other hosted resources. Azure PowerShell cmdlets can also work programmatically, thus scheduling and automating different complex tasks.

How to install Azure PowerShell

There are two different ways to install Azure PowerShell, an online installation downloading the module from the PowerShell Gallery and using an MSI installer for scenarios where the PowerShell gallery is unreachable, or an offline installer is required.

Installation from the PS Gallery

    1. Open an elevated PowerShell prompt and in order to allow the execution of scripts signed by a trusted publisher run Set-ExecutionPolicy RemoteSigned
    1. Run Install-Module -Name Az -AllowClobber

**If the NuGet provider is not installed in the system or an old version is present, it can be automatically installed or upgraded during the process.

**The Nupkg file can be manually downloaded from the gallery and unzipped in the %WINDIR%\System32\WindowsPowerShell\v1.0\Modules folder before running the installation command.

Install with MSI

The MSI installer is available to install Azure PowerShell for PowerShell 5.1 only and can be downloaded from the following website GitHub repository. The MSI installer will automatically remove previously installed versions of Azure PowerShell.

Once the module has been installed, to start working with Azure PowerShell open a PowerShell command prompt and run the Connect-AzAccount command.

Figure 1 - Getting started with Azure PowerShell

Different methods can be used when authenticating into Azure. Some examples can be found in the following link Authentication Methods.

Essential cmdlets to manage virtual machines on Azure

There are several cmdlets in Azure PowerShell. Different commands to manage virtual machines will be shown below:

Get-AzVM: Gets the properties of a virtual machine

Figure 2 - Getting started with Azure PowerShell

Start-AzVM: Starts an Azure Virtual Machine

Stop-AzVM: Stops an Azure Virtual Machine

Restart-AzVM: Restarts an Azure virtual machine

Figure 3 - Getting started with Azure PowerShell

Update-AzVM: Updates the state of an Azure virtual machine.

New-AzVMConfig: Creates a configurable virtual machine object for Azure.

New-AzVM: Creates a new virtual machine in Azure. When creating a new virtual machine with Azure PowerShell, it is recommended to define a configuration object specifying all the parameters, including machine name, subnet, operating system or size. For this example, all configuration values have been specified as parameters.

Figure 4 - Getting started with Azure PowerShell

Figure 5 - Getting started with Azure PowerShell

Figure 6 - Getting started with Azure PowerShell

Figure 7 - Getting started with Azure PowerShell

Remove-AzVM: Removes a virtual machine from Azure

Although cmdlets to manage virtual machines will be probably some of the most frequently used, Azure PowerShell also includes a complete set of commands to manage other resources.

Managing your Azure Cloud infrastructure with Parallels RAS

Parallels RAS supports both hybrid and cloud deployments in Microsoft Azure providing safe, scalable and reliable access to published applications and desktops. Parallels RAS supports Microsoft Azure Hypervisor as a virtual desktop infrastructure (VDI) provider; hence, companies will be able to provision and scale desktops on-demand directly on Azure.

Parallels RAS provides built-in automation capabilities to simplify its management and configuration in the Azure cloud. Combining RAS PowerShell SDK and Azure cmdlets, administrators will have the chance to automate several tasks to enhance their resource usage, thus saving time and costs.

Download a free trial of Parallels RAS to try it out for yourself.


Overview of Azure PowerShell

Install Azure PowerShell