Last active
December 28, 2015 05:49
-
-
Save glombard/7452810 to your computer and use it in GitHub Desktop.
Starting an Azure Virtual Machine from the command-line with PowerShell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Get WebPICmd from: http://go.microsoft.com/fwlink/?LinkId=255386 | |
# Direct download link: | |
# x64: http://download.microsoft.com/download/7/0/4/704CEB4C-9F42-4962-A2B0-5C84B0682C7A/WebPlatformInstaller_amd64_en-US.msi | |
# x86: http://download.microsoft.com/download/7/0/4/704CEB4C-9F42-4962-A2B0-5C84B0682C7A/WebPlatformInstaller_x86_en-US.msi | |
webpicmd /Install /Products:WindowsAzurePowershell /AcceptEula | |
webpicmd /List /ListOption:Installed | findstr "PowerShell" | |
# Import-Module "${env:ProgramFiles(x86)}\Microsoft SDKs\Windows Azure\PowerShell\Azure\Azure.psd1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
For a list of all Azure cmdlets type 'help azure'. | |
For a list of Windows Azure Pack cmdlets type 'Get-Command *wapack*'. | |
For Node.js cmdlets type 'help node-dev'. | |
For PHP cmdlets type 'help php-dev'. | |
For Python cmdlets type 'help python-dev'. | |
C:\> Add-AzureAccount | |
VERBOSE: Account "[email protected]" has been added. | |
VERBOSE: Subscription "Visual Studio Ultimate with MSDN" is selected as the default subscription. | |
VERBOSE: To view all the subscriptions, please use Get-AzureSubscription. | |
VERBOSE: To switch to a different subscription, please use Select-AzureSubscription. | |
Get-AzureAccount | |
Get-AzurePublishSettingsFile | |
$file = dir ~\Downloads\*credentials.publishsettings | sort LastWriteTime -Descending | select -expand FullName | |
Import-AzurePublishSettingsFile -PublishSettingsFile $file | |
del $file | |
Get-AzureSubscription |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Start the Azure Virtual Machine first: | |
$name = 'MyVM' | |
Start-AzureVM -Name $name -ServiceName $name | |
Get-AzureVM | |
# Start Remote Desktop session: | |
$port = get-AzureVM -ServiceName $name | Get-AzureEndpoint -Name 'Remote Desktop' | select -ExpandProperty Port | |
$server = "${name}.cloudapp.net:$port" | |
Invoke-Expression "mstsc.exe /v:$server /f" | |
# Stop-AzureVM -ServiceName $name -Name $name -StayProvisioned |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment