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, then you’re all set with the newest version of PowerShell.
Download and install the Windows Azure PowerShell cmdlets. Note that a restart may be required after installing this module.
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
Download and save your Windows Azure Publish Settings file by running the following command at the PowerShell command prompt:
PS C:\> Get-AzurePublishSettingsFile
Import the saved Windows Azure Publish Settings file by running the following command (no "<"s, and with your full path to your .publishsettings file) at the PowerShell command prompt:
PS C:\> Import-AzurePublishSettingsFile "<full_path_to_your_saved_file>.publishsettings"
And there you have it! The importing of that .publishsettings file has installed the proper certificate locally so that your PowerShell session will be authenticated, and have a secured interaction with your Windows Azure subscription.
To test it, run the following command from the PowerShell command prompt:
PS C:\> Get-AzureSubscription
This should return some details about your subscription.