Note
Access to this page requires authorization. You can try signing in or .
Access to this page requires authorization. You can try .
New-AzVM
- Module:
- Az.Compute Module
Creates a virtual machine.
Syntax
SimpleParameterSet (Default)
New-AzVM
[[-ResourceGroupName] <String>]
[[-Location] <String>]
[[-Zone] <String[]>]
-Name <String>
-Credential <PSCredential>
[-EdgeZone <String>]
[-PublicIpSku <String>]
[-NetworkInterfaceDeleteOption <String>]
[-VirtualNetworkName <String>]
[-AddressPrefix <String>]
[-SubnetName <String>]
[-SubnetAddressPrefix <String>]
[-PublicIpAddressName <String>]
[-DomainNameLabel <String>]
[-AllocationMethod <String>]
[-SecurityGroupName <String>]
[-OpenPorts <Int32[]>]
[-Image <String>]
[-Size <String>]
[-AvailabilitySetName <String>]
[-SystemAssignedIdentity]
[-UserAssignedIdentity <String>]
[-AsJob]
[-OSDiskDeleteOption <String>]
[-DataDiskSizeInGb <Int32[]>]
[-DataDiskDeleteOption <String>]
[-EnableUltraSSD]
[-ProximityPlacementGroupId <String>]
[-HostId <String>]
[-VmssId <String>]
[-Priority <String>]
[-EvictionPolicy <String>]
[-MaxPrice <Double>]
[-EncryptionAtHost]
[-HostGroupId <String>]
[-SshKeyName <String>]
[-GenerateSshKey]
[-CapacityReservationGroupId <String>]
[-UserData <String>]
[-ImageReferenceId <String>]
[-PlatformFaultDomain <Int32>]
[-HibernationEnabled]
[-vCPUCountAvailable <Int32>]
[-vCPUCountPerCore <Int32>]
[-DiskControllerType <String>]
[-SharedGalleryImageId <String>]
[-SecurityType <String>]
[-EnableVtpm <Boolean>]
[-EnableSecureBoot <Boolean>]
[-IfMatch <String>]
[-IfNoneMatch <String>]
[-SshKeyType <String>]
[-ZonePlacementPolicy <String>]
[-IncludeZone <String[]>]
[-ExcludeZone <String[]>]
[-AlignRegionalDisksToVMZone]
[-EnableProxyAgent]
[-AddProxyAgentExtension]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
DefaultParameterSet
New-AzVM
[-ResourceGroupName] <String>
[-Location] <String>
[-VM] <PSVirtualMachine>
[[-Zone] <String[]>]
[-EdgeZone <String>]
[-DisableBginfoExtension]
[-Tag <Hashtable>]
[-LicenseType <String>]
[-AsJob]
[-OSDiskDeleteOption <String>]
[-DataDiskDeleteOption <String>]
[-SshKeyName <String>]
[-GenerateSshKey]
[-vCPUCountAvailable <Int32>]
[-vCPUCountPerCore <Int32>]
[-IfMatch <String>]
[-IfNoneMatch <String>]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
DiskFileParameterSet
New-AzVM
[[-ResourceGroupName] <String>]
[[-Location] <String>]
-Name <String>
-DiskFile <String>
[-EdgeZone <String>]
[-PublicIpSku <String>]
[-NetworkInterfaceDeleteOption <String>]
[-VirtualNetworkName <String>]
[-AddressPrefix <String>]
[-SubnetName <String>]
[-SubnetAddressPrefix <String>]
[-PublicIpAddressName <String>]
[-DomainNameLabel <String>]
[-AllocationMethod <String>]
[-SecurityGroupName <String>]
[-OpenPorts <Int32[]>]
[-Linux]
[-Size <String>]
[-AvailabilitySetName <String>]
[-SystemAssignedIdentity]
[-UserAssignedIdentity <String>]
[-AsJob]
[-OSDiskDeleteOption <String>]
[-DataDiskSizeInGb <Int32[]>]
[-DataDiskDeleteOption <String>]
[-EnableUltraSSD]
[-ProximityPlacementGroupId <String>]
[-HostId <String>]
[-VmssId <String>]
[-Priority <String>]
[-EvictionPolicy <String>]
[-MaxPrice <Double>]
[-EncryptionAtHost]
[-HostGroupId <String>]
[-CapacityReservationGroupId <String>]
[-UserData <String>]
[-PlatformFaultDomain <Int32>]
[-HibernationEnabled]
[-vCPUCountAvailable <Int32>]
[-vCPUCountPerCore <Int32>]
[-IfMatch <String>]
[-IfNoneMatch <String>]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Description
The New-AzVM cmdlet creates a virtual machine in Azure.
This cmdlet takes a virtual machine object as input. The New-AzVM cmdlet will create a new storage account for boot diagnostics if one does not already exist.
Use the New-AzVMConfig cmdlet to create a virtual machine object.
Then use the following cmdlets to set different properties of the virtual machine object:
- Add-AzVMNetworkInterface to set the network profile.
- Set-AzVMOperatingSystem to set the OS profile.
- Set-AzVMSourceImage to set the source image.
- Set-AzVMOSDisk to set the OS disk(storage profile).
- Get-AzComputeResourceSku can also be used to find out available virtual machine sizes for your subscription and region.
The SimpleParameterSet provides a convenient method to create a VM by making common VM creation arguments optional.
See Quickstart: Create a Windows virtual machine in Azure with PowerShell for tutorial.
Examples
Example 1: Create a virtual machine
New-AzVM -Name MyVm -Credential (Get-Credential)
VERBOSE: Use 'mstsc /v:myvm-222222.eastus.cloudapp.azure.com' to connect to the VM.
ResourceGroupName : MyVm
Id : /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MyVm/provi
ders/Microsoft.Compute/virtualMachines/MyVm
VmId : 11111111-1111-1111-1111-111111111111
Name : MyVm
Type : Microsoft.Compute/virtualMachines
Location : eastus
Tags : {}
HardwareProfile : {VmSize}
NetworkProfile : {NetworkInterfaces}
OSProfile : {ComputerName, AdminUsername, WindowsConfiguration, Secrets}
ProvisioningState : Succeeded
StorageProfile : {ImageReference, OsDisk, DataDisks}
FullyQualifiedDomainName : myvm-222222.eastus.cloudapp.azure.com
This example script shows how to create a virtual machine. The script will ask a user name and password for the VM. This script uses several other cmdlets.
Example 2: Create a virtual machine from a custom user image
## VM Account
# Credentials for Local Admin account you created in the sysprepped (generalized) vhd image
$VMLocalAdminUser = "LocalAdminUser"
$VMLocalAdminSecurePassword = ConvertTo-SecureString -String "****" -AsPlainText -Force
## Azure Account
$LocationName = "westus"
$ResourceGroupName = "MyResourceGroup"
# This a Premium_LRS storage account.
# It is required in order to run a client VM with efficiency and high performance.
$StorageAccount = "Mydisk"
## VM
$OSDiskName = "MyClient"
$ComputerName = "MyClientVM"
$OSDiskUri = "https://Mydisk.blob.core.windows.net/disks/MyOSDisk.vhd"
$SourceImageUri = "https://Mydisk.blob.core.windows.net/vhds/MyOSImage.vhd"
$VMName = "MyVM"
# Modern hardware environment with fast disk, high IOPs performance.
# Required to run a client VM with efficiency and performance
$VMSize = "Standard_DS3"
$OSDiskCaching = "ReadWrite"
$OSCreateOption = "FromImage"
## Networking
$DNSNameLabel = "mydnsname" # mydnsname.westus.cloudapp.azure.com
$NetworkName = "MyNet"
$NICName = "MyNIC"
$PublicIPAddressName = "MyPIP"
$SubnetName = "MySubnet"
$SubnetAddressPrefix = "10.0.0.0/24"
$VnetAddressPrefix = "10.0.0.0/16"
$SingleSubnet = New-AzVirtualNetworkSubnetConfig -Name $SubnetName -AddressPrefix $SubnetAddressPrefix
$Vnet = New-AzVirtualNetwork -Name $NetworkName -ResourceGroupName $ResourceGroupName -Location $LocationName -AddressPrefix $VnetAddressPrefix -Subnet $SingleSubnet
$PIP = New-AzPublicIpAddress -Name $PublicIPAddressName -DomainNameLabel $DNSNameLabel -ResourceGroupName $ResourceGroupName -Location $LocationName -AllocationMethod Dynamic
$NIC = New-AzNetworkInterface -Name $NICName -ResourceGroupName $ResourceGroupName -Location $LocationName -SubnetId $Vnet.Subnets[0].Id -PublicIpAddressId $PIP.Id
$Credential = New-Object System.Management.Automation.PSCredential ($VMLocalAdminUser, $VMLocalAdminSecurePassword);
$securityTypeStnd = "Standard"
$VirtualMachine = New-AzVMConfig -VMName $VMName -VMSize $VMSize -SecurityType $securityTypeStnd
$VirtualMachine = Set-AzVMOperatingSystem -VM $VirtualMachine -Windows -ComputerName $ComputerName -Credential $Credential -ProvisionVMAgent -EnableAutoUpdate
$VirtualMachine = Add-AzVMNetworkInterface -VM $VirtualMachine -Id $NIC.Id
$VirtualMachine = Set-AzVMOSDisk -VM $VirtualMachine -Name $OSDiskName -VhdUri $OSDiskUri -SourceImageUri $SourceImageUri -Caching $OSDiskCaching -CreateOption $OSCreateOption -Windows
New-AzVM -ResourceGroupName $ResourceGroupName -Location $LocationName -VM $VirtualMachine -Verbose -Zone @("1")
This example takes an existing sys-prepped, generalized custom operating system image and attaches a data disk to it, provisions a new network, deploys the VHD, and runs it. This script can be used for automatic provisioning because it uses the local virtual machine admin credentials inline instead of calling Get-Credential which requires user interaction. This script assumes that you are already logged into your Azure account. You can confirm your login status by using the Get-AzSubscription cmdlet.
Example 3: Create a VM from a marketplace image without a Public IP
$VMLocalAdminUser = "LocalAdminUser"
$VMLocalAdminSecurePassword = ConvertTo-SecureString -String "****" -AsPlainText -Force
$LocationName = "eastus2"
$ResourceGroupName = "MyResourceGroup"
$ComputerName = "MyVM"
$VMName = "MyVM"
$VMSize = "Standard_DS3"
$NetworkName = "MyNet"
$NICName = "MyNIC"
$SubnetName = "MySubnet"
$SubnetAddressPrefix = "10.0.0.0/24"
$VnetAddressPrefix = "10.0.0.0/16"
$SingleSubnet = New-AzVirtualNetworkSubnetConfig -Name $SubnetName -AddressPrefix $SubnetAddressPrefix
$Vnet = New-AzVirtualNetwork -Name $NetworkName -ResourceGroupName $ResourceGroupName -Location $LocationName -AddressPrefix $VnetAddressPrefix -Subnet $SingleSubnet
$NIC = New-AzNetworkInterface -Name $NICName -ResourceGroupName $ResourceGroupName -Location $LocationName -SubnetId $Vnet.Subnets[0].Id
$Credential = New-Object System.Management.Automation.PSCredential ($VMLocalAdminUser, $VMLocalAdminSecurePassword);
$VirtualMachine = New-AzVMConfig -VMName $VMName -VMSize $VMSize
$VirtualMachine = Set-AzVMOperatingSystem -VM $VirtualMachine -Windows -ComputerName $ComputerName -Credential $Credential -ProvisionVMAgent -EnableAutoUpdate
$VirtualMachine = Add-AzVMNetworkInterface -VM $VirtualMachine -Id $NIC.Id
$VirtualMachine = Set-AzVMSourceImage -VM $VirtualMachine -PublisherName 'MicrosoftWindowsServer' -Offer 'WindowsServer' -Skus '2022-datacenter-azure-edition-core' -Version latest
New-AzVM -ResourceGroupName $ResourceGroupName -Location $LocationName -VM $VirtualMachine -Verbose
This command creates a VM from a marketplace image without a Public IP.
Example 4: Create a VM with a UserData value:
# VM Account
$VMLocalAdminUser = "LocalAdminUser";
$VMLocalAdminSecurePassword = ConvertTo-SecureString -String "****" -AsPlainText -Force;
# Azure Account
$LocationName = "eastus";
$ResourceGroupName = "MyResourceGroup";
# VM Profile & Hardware
$VMName = 'v' + $ResourceGroupName;
$domainNameLabel = "d1" + $ResourceGroupName;
$Credential = New-Object System.Management.Automation.PSCredential ($VMLocalAdminUser, $VMLocalAdminSecurePassword);
# Create UserData value
$text = "text for UserData";
$bytes = [System.Text.Encoding]::Unicode.GetBytes($text);
$userData = [Convert]::ToBase64String($bytes);
# Create VM
New-AzVM -ResourceGroupName $ResourceGroupName -Name $VMName -Credential $Credential -DomainNameLabel $domainNameLabel -UserData $userData;
$vm = Get-AzVM -ResourceGroupName $ResourceGroupName -Name $VMName -UserData;
The UserData value must always be Base64 encoded.
Example 5: Creating a new VM with an existing subnet in another resource group
$UserName = "User"
$Password = ConvertTo-SecureString -String "****" -AsPlainText -Force
$psCred = New-Object System.Management.Automation.PSCredential($UserName, $Password)
$Vnet = $(Get-AzVirtualNetwork -ResourceGroupName ResourceGroup2 -Name VnetName)
$PIP = (Get-AzPublicIpAddress -ResourceGroupName ResourceGroup2 -Name PublicIPName)
$NIC = New-AzNetworkInterface -Name NICname -ResourceGroupName ResourceGroup2 -Location SouthCentralUS -SubnetId $Vnet.Subnets[1].Id -PublicIpAddressId $PIP.Id
$VirtualMachine = New-AzVMConfig -VMName VirtualMachineName -VMSize Standard_D4s_v3
$VirtualMachine = Set-AzVMOperatingSystem -VM $VirtualMachine -Windows -ComputerName computerName -Credential $psCred -ProvisionVMAgent -EnableAutoUpdate
$VirtualMachine = Add-AzVMNetworkInterface -VM $VirtualMachine -Id $NIC.Id
$VirtualMachine = Set-AzVMSourceImage -VM $VirtualMachine -PublisherName 'MicrosoftWindowsServer' -Offer 'WindowsServer' -Skus '2022-datacenter-azure-edition-core' -Version latest
New-AzVM -ResourceGroupName ResourceGroup1 -Location SouthCentralUS -VM $VirtualMachine
This example deploys a Windows VM from the marketplace in one resource group with an existing subnet in another resource group.
Example 6: Creating a new VM as part of a VMSS with a PlatformFaultDomain value.
$resourceGroupName= "ResourceGroupName";
$loc = 'eastus';
New-AzResourceGroup -Name $resourceGroupName -Location $loc -Force;
$domainNameLabel = "d1" + $resourceGroupName;
$vmname = "vm" + $resourceGroupName;
$platformFaultDomainVMDefaultSet = 2;
$vmssFaultDomain = 3;
$securePassword = ConvertTo-SecureString -String "****" -AsPlainText -Force;
$user = <USERNAME>;
$cred = New-Object System.Management.Automation.PSCredential ($user, $securePassword);
$vmssName = "vmss" + $resourceGroupName;
$vmssConfig = New-AzVmssConfig -Location $loc -PlatformFaultDomainCount $vmssFaultDomain;
$vmss = New-AzVmss -ResourceGroupName $resourceGroupName -Name $vmssName -VirtualMachineScaleSet $vmssConfig;
$vm = New-AzVM -ResourceGroupName $resourceGroupName -Name $vmname -Credential $cred -DomainNameLabel $domainNameLabel -PlatformFaultDomain $platformFaultDomainVMDefaultSet -VmssId $vmss.Id;
This example creates a new VM as part of a VMSS with a PlatformFaultDomain value.
Example 7: Create a VM using the -Image alias.
$resourceGroupName= "<Resource Group Name>"
$loc = "<Azure Region>"
$domainNameLabel = "<Domain Name Label>"
$vmname = "<Virtual Machine Name>"
$securePassword = ConvertTo-SecureString -String "****" -AsPlainText -Force
$user = "<Username>"
$cred = New-Object System.Management.Automation.PSCredential ($user, $securePassword)
New-AzResourceGroup -Name $resourceGroupName -Location $loc -Force
# Create a VM using an Image alias.
$vmname = 'v' + $resourceGroupName
$domainNameLabel = "d" + $resourceGroupName
$vm = New-AzVM -ResourceGroupName $resourceGroupName -Name $vmname -Credential $cred -Image OpenSuseLeap154Gen2 -DomainNameLabel $domainNameLabel
$vm = Get-AzVM -ResourceGroupName $resourceGroupName -Name $vmname
This example creates a new VM using the -Image parameter, providing many default values to the VM.
Example 8: Creating a VM for Trusted Launch SecurityType.
$rgname = <Resource Group Name>;
$loc = "eastus";
New-AzResourceGroup -Name $rgname -Location $loc -Force;
# VM Profile & Hardware
$domainNameLabel1 = 'd1' + $rgname;
$vmsize = 'Standard_D4s_v3';
$vmname1 = 'v' + $rgname;
$imageName = "Win2022AzureEdition";
$disable = $false;
$enable = $true;
$securityType = "TrustedLaunch";
$securePassword = ConvertTo-SecureString -String "****" -AsPlainText -Force;
$user = <Username>;
$cred = New-Object System.Management.Automation.PSCredential ($user, $securePassword);
# VM creation using Simple parameterset
New-AzVM -ResourceGroupName $rgname -Location $loc -Name $vmname1 -Credential $cred -Size $vmsize -Image $imageName -DomainNameLabel $domainNameLabel1 -SecurityType $securityType;
$vm1 = Get-AzVM -ResourceGroupName $rgname -Name $vmname1;
# Verify Values
#$vm1.SecurityProfile.SecurityType "TrustedLaunch";
#$vm1.SecurityProfile.UefiSettings.VTpmEnabled $true;
#$vm1.SecurityProfile.UefiSettings.SecureBootEnabled $true;
This example Creates a new VM with the TrustedLaunch Security Type and sets flags EnableSecureBoot and EnableVtpm as True by default. A Trusted Launch VM requires a Gen2 image. Please check the Trusted Launch feature page for more information.
Example 9: Create a VM with Trusted Launch turned on by default using New-AzVMConfig.
$rgname = "<Resource Group Name>";
$loc = "<Azure Region>";
$vmname = 'vm' + $rgname;
$domainNameLabel = "d1" + $rgname;
$vnetname = "vn" + $rgname;
$vnetAddress = "10.0.0.0/16";
$subnetname = "slb" + $rgname;
$subnetAddress = "10.0.2.0/24";
$OSDiskName = $vmname + "-osdisk";
$NICName = $vmname+ "-nic";
$NSGName = $vmname + "-NSG";
$OSDiskSizeinGB = 128;
$VMSize = "Standard_DS2_v2";
$PublisherName = "MicrosoftWindowsServer";
$Offer = "WindowsServer";
$SKU = "2022-datacenter-azure-edition";
$version = "latest";
$securePassword = ConvertTo-SecureString -String "****" -AsPlainText -Force;
$user = <Username>;
$cred = New-Object System.Management.Automation.PSCredential ($user, $securePassword);
# Network setup
$frontendSubnet = New-AzVirtualNetworkSubnetConfig -Name $subnetname -AddressPrefix $subnetAddress;
$vnet = New-AzVirtualNetwork -Name $vnetname -ResourceGroupName $rgname -Location $loc -AddressPrefix $vnetAddress -Subnet $frontendSubnet;
$nsgRuleRDP = New-AzNetworkSecurityRuleConfig -Name RDP -Protocol Tcp -Direction Inbound -Priority 1001 -SourceAddressPrefix * -SourcePortRange * -DestinationAddressPrefix * -DestinationPortRange 3389 -Access Allow;
$nsg = New-AzNetworkSecurityGroup -ResourceGroupName $RGName -Location $loc -Name $NSGName -SecurityRules $nsgRuleRDP;
$nic = New-AzNetworkInterface -Name $NICName -ResourceGroupName $RGName -Location $loc -SubnetId $vnet.Subnets[0].Id -NetworkSecurityGroupId $nsg.Id -EnableAcceleratedNetworking;
# VM
$vmConfig = New-AzVMConfig -VMName $vmName -VMSize $VMSize;
Set-AzVMOperatingSystem -VM $vmConfig -Windows -ComputerName $vmName -Credential $cred;
Set-AzVMSourceImage -VM $vmConfig -PublisherName $PublisherName -Offer $Offer -Skus $SKU -Version $version ;
Add-AzVMNetworkInterface -VM $vmConfig -Id $nic.Id;
New-AzVM -ResourceGroupName $rgname -Location $loc -VM $vmConfig;
$vm = Get-AzVM -ResourceGroupName $rgname -Name $vmname;
# Verify $vm.SecurityProfile.SecurityType is TrustedLaunch
# Verify $vm.SecurityProfile.UefiSettings.SecureBootEnabled is true.
# Verify $vm.SecurityProfile.UefiSettings.VTpmEnabled is true.
This example shows how to create a VM with a valid Gen2 image, allowing the VM to default to TrustedLaunch which requires Gen2 images. Please check the Trusted Launch feature page for more information.
Example 10: Creates a VM with TrustedLaunch turned on by default.
$rgname = "<Resource Group Name>";
$loc = "<Azure Region>";
$vmname = 'vm' + $rgname;
$domainNameLabel = "d1" + $rgname;
$securePassword = ConvertTo-SecureString -String "****" -AsPlainText -Force;
$user = <Username>;
$cred = New-Object System.Management.Automation.PSCredential ($user, $securePassword);
# Create VM
$vm = New-AzVM -ResourceGroupName $rgname -Name $vmname -Credential $cred -DomainNameLabel $domainNameLabel;
$vm = Get-AzVM -ResourceGroupName $rgname -Name $vmname;
# Verify $vm.SecurityProfile.SecurityType is TrustedLaunch.
# Verify the $vm.StorageProfile.ImageReference.Sku has defaulted to "2022-datacenter-azure-edition", a Gen2 image.
This example shows how the simple cmdlet call with minimal parameters will result in a TrustedLaunch enabled VM with a Gen2 image. Please check the Trusted Launch feature page for more information.
=======
Parameters
-AddProxyAgentExtension
Specifies whether to implicitly install the ProxyAgent Extension. This option is currently applicable only for Linux OS.
Parameter properties
| Type: | SwitchParameter |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-AddressPrefix
The address prefix for the virtual network which will be created for the VM.
Parameter properties
| Type: | String |
| Default value: | 192.168.0.0/16 |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-AlignRegionalDisksToVMZone
Specifies whether the regional disks should be aligned/moved to the VM zone. This is applicable only for VMs with placement property set. Please note that this change is irreversible.
Parameter properties
| Type: | SwitchParameter |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-AllocationMethod
The IP allocation method for the public IP which will be created for the VM.
Parameter properties
| Type: | String |
| Default value: | Static |
| Accepted values: | Static, Dynamic |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-AsJob
Run cmdlet in the background and return a Job to track progress.
Parameter properties
| Type: | SwitchParameter |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-AvailabilitySetName
Specifies a name for the availability set.
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-CapacityReservationGroupId
Id of the capacity reservation Group that is used to allocate.
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-Confirm
Prompts you for confirmation before running the cmdlet.
Parameter properties
| Type: | SwitchParameter |
| Default value: | False |
| Supports wildcards: | False |
| DontShow: | False |
| Aliases: | cf |
Parameter sets
-Credential
The administrator credentials for the VM.
Username
Restriction:
Windows: Cannot contain special characters /""[]:|<>+=;,?*@& or end in "."
Linux: Username must only contain letters, numbers, hyphens, and underscores and may not start with a hyphen or number.
Disallowed values: "administrator", "admin", "user", "user1", "test", "user2", "test1", "user3", "admin1", "1", "123", "a", "actuser", "adm", "admin2", "aspnet", "backup", "console", "david", "guest", "john", "owner", "root", "server", "sql", "support", "support_388945a0", "sys", "test2", "test3", "user4", "user5".
Minimum-length: 1 character
Max-length: 20 characters for Windows, 64 characters for Linux
Password
Must have 3 of the following: 1 lower case character, 1 upper case character, 1 number, and 1 special character.
The value must be between 12 and 123 characters long.
Parameter properties
| Type: | PSCredential |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-DataDiskDeleteOption
Specifies Data Disk delete option after VM deletion. Options are Detach, Delete
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-DataDiskSizeInGb
Specifies the sizes of data disks in GB.
Parameter properties
| Type: | Int32[] |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-DefaultProfile
The credentials, account, tenant, and subscription used for communication with azure.
Parameter properties
| Type: | IAzureContextContainer |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
| Aliases: | AzContext, AzureRmContext, AzureCredential |
Parameter sets
-DisableBginfoExtension
Indicates that this cmdlet does not install the BG Info extension on the virtual machine.
Parameter properties
| Type: | SwitchParameter |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-DiskControllerType
Specifies the disk controller type configured for the VM and VirtualMachineScaleSet. This property is only supported for virtual machines whose operating system disk and VM sku supports Generation 2 (https://learn.microsoft.com/en-us/azure/virtual-machines/generation-2), please check the HyperVGenerations capability returned as part of VM sku capabilities in the response of Microsoft.Compute SKUs api for the region contains V2 (https://learn.microsoft.com/rest/api/compute/resourceskus/list) .
For more information about Disk Controller Types supported please refer to https://aka.ms/azure-diskcontrollertypes.
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-DiskFile
The local path to the virtual hard disk file to be uploaded to the cloud and for creating the VM, and it must have '.vhd' as its suffix.
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-DomainNameLabel
The subdomain label for the fully-qualified domain name (FQDN) of the VM. This will take the form {domainNameLabel}.{location}.cloudapp.azure.com.
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-EdgeZone
Sets the edge zone name. If set, the query will be routed to the specified edgezone instead of the main region.
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-EnableProxyAgent
Specifies whether Metadata Security Protocol(ProxyAgent) feature should be enabled or not.
Parameter properties
| Type: | SwitchParameter |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-EnableSecureBoot
Specifies whether secure boot should be enabled on the virtual machine.
Parameter properties
| Type: | |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-EnableUltraSSD
Use UltraSSD disks for the vm.
Parameter properties
| Type: | SwitchParameter |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-EnableVtpm
Specifies whether vTPM should be enabled on the virtual machine.
Parameter properties
| Type: | |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-EncryptionAtHost
EncryptionAtHost property can be used by user in the request to enable or disable the Host Encryption for the virtual machine or virtual machine scale set. This will enable the encryption for all the disks including Resource/Temp disk at host itself. Default: The Encryption at host will be disabled unless this property is set to true for the resource.
Parameter properties
| Type: | SwitchParameter |
| Default value: | False |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-EvictionPolicy
The eviction policy for the Azure Spot virtual machine. Supported values are 'Deallocate' and 'Delete'.
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-ExcludeZone
This property supplements the 'zonePlacementPolicy' property. If 'zonePlacementPolicy' is set to 'Any', availability zone selected by the system must not be present in the list of availability zones passed with 'excludeZones'. If 'excludeZones' is not provided, all availability zones in region will be considered for selection.
Parameter properties
| Type: | String[] |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-GenerateSshKey
Generate a SSH Public/Private key pair and create a SSH Public Key resource on Azure.
Parameter properties
| Type: | SwitchParameter |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-HibernationEnabled
The flag that enables or disables hibernation capability on the VM.
Parameter properties
| Type: | SwitchParameter |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-HostGroupId
Specifies the dedicated host group the virtual machine will reside in.
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-HostId
The Id of Host
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-IfMatch
used to make a request conditional for the PUT and other non-safe methods. The server will only return the requested resources if the resource matches one of the listed ETag values. Omit this value to always overwrite the current resource. Specify the last-seen ETag value to prevent accidentally overwriting concurrent changes.
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-IfNoneMatch
Used to make a request conditional for the GET and HEAD methods. The server will only return the requested resources if none of the listed ETag values match the current entity. Used to make a request conditional for the GET and HEAD methods. The server will only return the requested resources if none of the listed ETag values match the current entity. Set to '*' to allow a new record set to be created, but to prevent updating an existing record set. Other values will result in error from server as they are not supported.
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-Image
The friendly image name upon which the VM will be built. The available aliases are: Win2022AzureEdition, Win2022AzureEditionCore, Win2019Datacenter, Win2016Datacenter, Win2012R2Datacenter, Win2012Datacenter, Ubuntu2204, CentOS85Gen2, Debian11, OpenSuseLeap154Gen2, RHELRaw8LVMGen2, SuseSles15SP3, FlatcarLinuxFreeGen2.
Parameter properties
| Type: | String |
| Default value: | Win2016Datacenter |
| Supports wildcards: | False |
| DontShow: | False |
| Aliases: | ImageName |
Parameter sets
-ImageReferenceId
Specified the shared gallery image unique id for vm deployment. This can be fetched from shared gallery image GET call.
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-IncludeZone
This property supplements the 'zonePlacementPolicy' property. If 'zonePlacementPolicy' is set to 'Any', availability zone selected by the system must be present in the list of availability zones passed with 'includeZones'. If 'includeZones' is not provided, all availability zones in region will be considered for selection.
Parameter properties
| Type: | String[] |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-LicenseType
Specifies a license type, which indicates that the image or disk for the virtual machine was licensed on-premises. Possible values for Windows Server are:
- Windows_Client
- Windows_Server
Possible values for Linux Server operating system are:
- RHEL_BYOS (for RHEL)
- SLES_BYOS (for SUSE)
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-Linux
Indicates whether the disk file is for Linux VM, if specified; or Windows, if not specified by default.
Parameter properties
| Type: | SwitchParameter |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-Location
Specifies a location for the virtual machine.
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-MaxPrice
The max price of the billing of a low priority virtual machine.
Parameter properties
| Type: | Double |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-Name
The name of the VM resource.
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-NetworkInterfaceDeleteOption
Specifies what action to perform on the NetworkInterface resource when the VM is deleted. Options are: Detach, Delete.
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-OpenPorts
A list of ports to open on the network security group (NSG) for the created VM. The default value depends on the type of image chosen (i.e., Windows: 3389, 5985 and Linux: 22).
Parameter properties
| Type: | Int32[] |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-OSDiskDeleteOption
Specifies OS Disk delete option after VM deletion. Options are Detach, Delete
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-PlatformFaultDomain
Specifies the fault domain of the virtual machine.
Parameter properties
| Type: | Int32 |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-Priority
The priority for the virtual machine. Only supported values are 'Regular', 'Spot' and 'Low'. 'Regular' is for regular virtual machine. 'Spot' is for spot virtual machine. 'Low' is also for spot virtual machine but is replaced by 'Spot'. Please use 'Spot' instead of 'Low'.
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-ProximityPlacementGroupId
The resource id of the Proximity Placement Group to use with this virtual machine.
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
| Aliases: | ProximityPlacementGroup |
Parameter sets
-PublicIpAddressName
The name of a new (or existing) public IP address for the created VM to use. If not specified, a name will be generated.
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-PublicIpSku
Specifies public IP sku name
Accepted values are "Basic" and "Standard"
Parameter properties
| Type: | String |
| Default value: | Standard |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-ResourceGroupName
Specifies the name of a resource group.
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-SecurityGroupName
The name of a new (or existing) network security group (NSG) for the created VM to use. If not specified, a name will be generated.
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-SecurityType
Specifies the SecurityType of the virtual machine. It has to be set to any specified value to enable UefiSettings. By default, UefiSettings will not be enabled unless this property is set.
Parameter properties
| Type: | String |
| Default value: | None |
| Accepted values: | TrustedLaunch, ConfidentialVM, Standard |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-SharedGalleryImageId
Specified the shared gallery image unique id for vm deployment. This can be fetched from shared gallery image GET call.
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-Size
The Virtual Machine Size. Get-AzComputeResourceSku can be used to find out available sizes for your subscription and region.
The Default Value is: Standard_D2s_v3.
Parameter properties
| Type: | String |
| Default value: | Standard_D2s_v3 |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-SshKeyName
Name of the SSH Public Key resource.
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-SshKeyType
Specify the type of SSH key to generate. Allowed values are 'Ed25519' and 'RSA'.
Parameter properties
| Type: | String |
| Default value: | None |
| Accepted values: | Ed25519, RSA |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-SubnetAddressPrefix
The address prefix for the subnet which will be created for the VM.
Parameter properties
| Type: | String |
| Default value: | 192.168.1.0/24 |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-SubnetName
The name of a new (or existing) subnet for the created VM to use. If not specified, a name will be generated.
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-SystemAssignedIdentity
If the parameter is present then the VM is assigned a managed system identity that is auto generated.
Parameter properties
| Type: | SwitchParameter |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-Tag
Specifies that resources and resource groups can be tagged with a set of name-value pairs. Adding tags to resources enables you to group resources together across resource groups and to create your own views. Each resource or resource group can have a maximum of 15 tags.
Parameter properties
| Type: | Hashtable |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-UserAssignedIdentity
The name of a managed service identity that should be assigned to the VM.
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-UserData
UserData for the VM, which will be base-64 encoded. Customer should not pass any secrets in here.
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-vCPUCountAvailable
Specifies the number of vCPUs available for the VM. When this property is not specified in the request body the default behavior is to set it to the value of vCPUs available for that VM size exposed in api response of List all available virtual machine sizes in a region.
Parameter properties
| Type: | Int32 |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-vCPUCountPerCore
Specifies the vCPU to physical core ratio. When this property is not specified in the request body the default behavior is set to the value of vCPUsPerCore for the VM Size exposed in api response of List all available virtual machine sizes in a region. Setting this property to 1 also means that hyper-threading is disabled.
Parameter properties
| Type: | Int32 |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-VirtualNetworkName
The name of a new (or existing) virtual network for the created VM to use. If not specified, a name will be generated.
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-VM
Specifies a local virtual machine to create. To obtain a virtual machine object, use the New-AzVMConfig cmdlet. Other cmdlets can be used to configure the virtual machine, such as Set-AzVMOperatingSystem, Set-AzVMSourceImage, and Add-AzVMNetworkInterface.
Parameter properties
| Type: | PSVirtualMachine |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
| Aliases: | VMProfile |
Parameter sets
-VmssId
The ID of Virtual Machine Scale Set that this VM will be associated with
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-WhatIf
Shows what would happen if the cmdlet runs. The cmdlet is not run.
Parameter properties
| Type: | SwitchParameter |
| Default value: | False |
| Supports wildcards: | False |
| DontShow: | False |
| Aliases: | wi |
Parameter sets
-Zone
Specifies the zone of the virtual machine. Although it takes in an array of zones, virtual machines do not support multiple availability zones. The allowed value depends on the capabilities of the region. Allowed value will normally be 1, 2, or 3. More information on Azure availability zones.
Parameter properties
| Type: | String[] |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-ZonePlacementPolicy
Specifies the policy for virtual machine's placement in availability zone. Possible values are: Any - An availability zone will be automatically picked by system as part of virtual machine creation.
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
Inputs
String
PSVirtualMachine
String
Hashtable
Outputs
PSAzureOperationResponse
PSVirtualMachine
Related Links
Azure PowerShell
Feedback
Was this page helpful?
