Get Started with Azure Cmdlets
Updated: January 15, 2015
Azure cmdlets are available so you can manage Azure with Windows PowerShell. To get started with these cmdlets, you’ll need to download and install Azure PowerShell, and then configure connectivity between your subscription and your Windows PowerShell environment. Instructions are available on the Azure website, in How to install and configure Azure PowerShell.
This article helps you understand how input, outputs, and parameters generally are handled in Azure. This information can make it easier to get started using Windows PowerShell with Azure.
Understanding inputs and outputs for Azure cmdlets
The cmdlets in the Azure module for Windows PowerShell behave like other Windows PowerShell cmdlets in that, in most cases, they can be part of a pipeline. They expect input from that pipeline in the form of an object, and they output an object to the next stage of the pipeline. If the next stage of the pipeline is simply the console, or if it is a cmdlet that doesn't expect to participate in a pipeline, then Windows PowerShell uses Format.ps1xml files to determine what to display from the object and how to display it. For more information about how to use the formatting files, see About_Format.ps1xml.
Parameters and virtual machines
The cmdlets in the Azure module expect most parameter values to be in the form of a string, especially when "name" is part of the parameter name. For example, the Get-AzureDeployment cmdlet accepts two parameters: ServiceName, and Slot. The ServiceName parameter is a required parameter while the Slot parameter is optional, but both expect strings.
When you create or modify virtual machines, however, the cmdlets manipulate a virtual machine object, and that object is passed through the pipeline. For example, you use the New-AzureVMConfig cmdlet to create a new configuration object. You pass that configuration object to other Azure cmdlets that modify it, and then to the New-AzureVM cmdlet, which uses the object to create the virtual machine.
Similarly, you can start by getting an object that represents an existing virtual machine with the Get-AzureVM cmdlet. You can modify that object by adding or removing elements of the virtual machine, such as data disks and virtual networks, and then you send the modified virtual machine object to the Update-AzureVM cmdlet, which implements the changes to the virtual machine.
This can be a bit confusing because the output from a cmdlet is an object, but related cmdlets might expect strings as inputs for parameters. For example, the Get-AzureSubscription cmdlet returns a list object that represents your current Azure subscriptions. But the other AzureSubscription cmdlets use SubscriptionName as the required parameter. Remember, whenever "Name" is a part of the parameter name, the parameter expects a string.
Determining input values for parameters
How can you tell what a specific Azure cmdlet expects? Use Windows PowerShell to tell you. To see complete details of a Azure cmdlet and the full details on each parameter, run "Get-Help -Full <cmdlet name>". This gives you detailed information about the parameters. Specifically, this command tells you:
What it expects as a value.
If the parameter is required.
What the parameter's position is.
If it has a default value.
Whether it accepts pipeline input (and what kind).
Whether it accepts wildcards.