Azure Virtual Machine PowerShell samples

The following table includes links to PowerShell scripts samples that create and manage Windows virtual machines.

Create virtual machines
Quickly create a virtual machine Creates a resource group, virtual machine, and all related resources, with the minimum of prompts.
Create a fully configured virtual machine Creates a resource group, virtual machine, and all related resources .
Create highly available virtual machines Creates several virtual machines in a highly available and load balanced configuration.
Create a VM and run configuration script Creates a virtual machine and uses the Azure Custom Script extension to install IIS.
Create a VM and run DSC configuration Creates a virtual machine and uses the Azure Desired State Configuration (DSC) extension to install IIS.
Upload a VHD and create VMs Uploads a local VHD file to Azure, creates and image from the VHD and then creates a VM from that image.
Create a VM from a managed OS disk Creates a virtual machine by attaching an existing Managed Disk as OS disk.
Create a VM from a snapshot Creates a virtual machine from a snapshot by first creating a managed disk from snapshot and then attaching the new managed disk as OS disk.
Manage storage
Create managed disk from a VHD in same or different subscription Creates a managed disk from a specialized VHD as a OS disk or from a data VHD as data disk in same or different subscription.
Create a managed disk from a snapshot Creates a managed disk from a snapshot.
Copy managed disk to same or different subscription Copies managed disk to same or different subscription but in the same region as the parent managed disk.
Export a snapshot as VHD to a storage account Exports a managed snapshot as VHD to a storage account in different region.
Create a snapshot from a VHD Creates snapshot from a VHD to create multiple identical managed disks from snapshot in short amount of time.
Copy snapshot to same or different subscription Copies snapshot to same or different subscription but in the same region as the parent snapshot.
Secure virtual machines
Encrypt a VM and data disks Creates an Azure Key Vault, encryption key, and service principal, then encrypts a VM.
Monitor virtual machines
Monitor a VM with Operations Management Suite Creates a virtual machine, installs the Operations Management Suite agent, and enrolls the VM in an OMS Workspace.