Skip to content

Instantly share code, notes, and snippets.

@ploegert
Created July 27, 2015 15:42
Show Gist options
  • Select an option

  • Save ploegert/b5bab70b5663c0e3c526 to your computer and use it in GitHub Desktop.

Select an option

Save ploegert/b5bab70b5663c0e3c526 to your computer and use it in GitHub Desktop.
Export VM, including Stopping VM, Exporting it, and then Deleting VM instance
Add-AzureAccount
$SubName = "be-dev"
Set-AzureSubscription -SubscriptionName $SubName
Select-AzureSubscription -SubscriptionName $SubName
$workingDir = "P:\posh\config\BE-Dev\VMs"
$vmName = "eisdev-dc01"
$serviceName = "eisdev-dc"
$filename = "iaas-" + $vmName +".xml"
$Vm = Get-AzureVM –ServiceName $serviceName –Name $vmName
$vmConfigurationPath = join-path $workingDir $filename
#ExportVM
$Vm | Export-AzureVM -Path $vmConfigurationPath
#Stop VM
#Stop-AzureVM –ServiceName $serviceName –Name $vmName -Force
#Remove VM
#$vm | Remove-AzureVM -Verbose
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment