Last active
January 24, 2018 14:35
-
-
Save msdotnetclr/7adfdba3000eb7269aed6633673252c0 to your computer and use it in GitHub Desktop.
Use PowerShell to start an Azure VM
This file contains hidden or 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
# --- begin prerequisite --- | |
# interactive login to Azure Resource Manager with your Azure Account | |
Login-AzureRmAccount | |
# print the list of subscriptions you have access to | |
Get-AzureRmSubscription | |
# save your credential to a JSON file for auto-login later on | |
Save-AzureRmContext -Path "C:\private\azure-credential.json" | |
# --- end prerequisite --- | |
# --- begin script --- | |
Import-AzureRmContext -Path "C:\private\azure-credential.json" | |
Select-AzureRmSubscription -SubscriptionName "MySubscription" | |
$vm = Get-AzureRmVM -ResourceGroupName "MyResourceGroup" -Name "MyVM" | |
$vm | Start-AzureRmVM | |
# --- end script --- |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment