Azure Virtual Machine PowerShell samples

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

Create virtual machines
Create a fully configured virtual machine Creates a resource group, virtual machine, and all related resources.
Create a VM with Docker enabled Creates a virtual machine, configures this VM as a Docker host, and runs an NGINX container.
Create a VM and run configuration script Creates a virtual machine and uses the Azure Custom Script extension to install NGINX.
Create a VM with WordPress installed Creates a virtual machine and uses the Azure Custom Script extension to install WordPress.
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 the snapshot and then attaching the new managed disk as OS disk.
Manage storage
Create a managed disk from a VHD in the same or a different subscription Creates a managed disk from a specialized VHD as an OS disk, or from a data VHD as a data disk, in the same or a different subscription.
Create a managed disk from a snapshot Creates a managed disk from a snapshot.
Export a snapshot as a VHD to a storage account Exports a managed snapshot as a VHD to a storage account in a different region.
Export the VHD of a managed disk to a storage account Exports the underlying VHD of a managed disk to a storage account in a different region.
Create a snapshot from a VHD Creates a snapshot from a VHD and then uses that snapshot to create multiple identical managed disks quickly.
Copy a snapshot to the same or a different subscription Copies snapshot to the same or a different subscription that is in the same region as the parent snapshot.
Monitor virtual machines
Monitor a VM with Azure Monitor logs Creates a virtual machine, installs the Log Analytics agent, and enrolls the VM in a Log Analytics workspace.
Copy a managed disk to the same or a different subscription Copies a managed disk to the same or a different subscription that is in the same region as the parent managed disk.
Collect details about all VMs in a subscription with PowerShell Creates a csv that contains the VM Name, Resource Group Name, Region, Virtual Network, Subnet, Private IP Address, OS Type, and Public IP Address of the VMs in the provided subscription.