PowerShell: Connecting to Azure!

Here comes the Azure PowerShell module!
To automate the provisioning and management of Window Azure, you’ll need the Azure PowerShell module. The Azure team makes this module available as a free download, and this module provides approximately 180 Windows PowerShell cmdlets for automating Azure storage, virtual machines, virtual networks, and other cloud services.

To get started, you’ll need the following prerequisite items:

An Azure subscription – If you don’t currently have a paid subscription, you can sign-up for a FREE trial subscription on the Azure account site.
Azure PowerShell module – Download and install the Azure PowerShell module on a PC running Windows PowerShell 2.0 or Windows PowerShell 3.0.
After you satisfy these prerequisites, you’ll be prepared to follow along with the rest of this post.

Connect PowerShell to your Azure subscription.
After downloading and installing the Azure PowerShell module, you need to perform the following initial steps from Windows PowerShell to configure connection information for your Azure subscription. After you perform these steps the first time, the configuration is saved locally, and you do not need to perform these steps again.

1. Set the Windows PowerShell script execution policy to RemoteSigned:

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned

2. Import the Azure PowerShell module:

Import-Module Azure

After you complete the steps in this section, Windows PowerShell is configured to connect to your Azure subscription. To test this connection, enter the following cmdlet to connect to Azure and enumerate your subscription information:


#Install AzureRM Module
Install-Module AzureRM

# To log in to Azure Resource Manager
$cred = Get-Credential -Credential Domain\User
Login-AzureRmAccount -Credential $cred

# To view all subscriptions for your account
Get-AzureRmSubscription | Select-AzureRmSubscription

# To select a default subscription for your current session.
Get-AzureRmSubscription -SubscriptionName $subscription | Select-AzureRmSubscription