So, you’ve got your Windows Azure subscription all set up (and if you don’t you can set up a FREE TRIAL HERE), and now you want to use PowerShell to work with your Windows Azure-based resources. In case you weren’t aware, Microsoft provides a Windows Azure PowerShell module for scripted management of Windows Azure services.
“Yes! That’s what I want, Kevin!”
Okay then… here’s how you do it:
If you’re running Windows 7 w/SP1, Windows Server 2008 R2 w/SP1, or Windows Server 2008 w/SP2, you’ll need the most recent version of the Windows Management Framework installed. This includes updates to Windows Remote Management (WinRM), Windows Management Instrumentation (WMI), and, importantly, Windows PowerShell 3.0.
If you’re running Windows 8 or Windows Server 2012 or newer, then you’re all set with the newest version of PowerShell.
Download and Install the Windows Azure PowerShell cmdlets
Launch Internet Explorer, and browse to the following link location: http://go.microsoft.com/?linkid=9811175
When prompted, click the Run button to run the installation program. The Web Platform Installer will launch.
On the Web Platform Installer dialog box, click the Install button.
When prompted for Prerequisites, click the I Accept button.
When the installation process has completed, click the Finish button and then click Exit.
Configure the Windows Azure PowerShell Module for your Windows Azure subscription
Right-click on Windows PowerShell in your Start Menu or Start Screen and choose Run As Administrator.
Set the PowerShell Execution Policy for scripts by running the following command at the PowerShell command prompt:
PS C:> Set-ExecutionPolicy RemoteSigned
Import the Windows Azure PowerShell module and supporting cmdlets by running the following command at the PowerShell command prompt:
PS C:> Import-Module Azure
Now run the following command to connect your system to your Azure subscription:
PS C:> Add-AzureAccount
When prompted to Sign in, sign in with the same Microsoft account (LiveID) or organization account credentials that you use for your Windows Azure subscription.
Confirm that your Windows Azure subscription has been properly connected via PowerShell by running the following cmdlet:
PS C:> Get-AzureSubscription
This should list all of the subscriptions that you currently are able to administer with your current login.
You can set the default Windows Azure subscription for your session by running the cmdlets below.
Be sure to substitute your subscription name that was listed in the Get-AzureSubscription cmdlet output.
PS C:> Select-AzureSubscription –Default “YOUR AZURE SUBSCRIPTION NAME”
And there you have it! You’ve automatically installed the proper certificate locally so that your PowerShell session will be authenticated and have a secured interaction with your Windows Azure subscription.