Edit

Share via


New-AzStackHCIVMVirtualMachine

The operation to create or update a virtual machine. Please note some properties can be set only during virtual machine creation.

Syntax

ByImageId (Default)

New-AzStackHCIVMVirtualMachine
    -Name <String>
    -ResourceGroupName <String>
    -Location <String>
    -CustomLocationId <String>
    -OsType <String>
    -ImageId <String>
    [-SubscriptionId <String>]
    [-DynamicMemoryMaximumMemoryInMb <Int64>]
    [-DynamicMemoryMinimumMemoryInMb <Int64>]
    [-DynamicMemoryTargetBuffer <Int32>]
    [-VmMemoryInMB <Int64>]
    [-VmProcessor <Int32>]
    [-VmSize <String>]
    [-IdentityType <String>]
    [-DisablePasswordAuthentication]
    [-ProvisionVMAgent]
    [-ProvisionVMConfigAgent]
    [-NicId <String[]>]
    [-NicName <String[]>]
    [-NicResourceGroup <String>]
    [-DataDiskId <String[]>]
    [-DataDiskName <String[]>]
    [-DataDiskResourceGroup <String>]
    [-AdminPassword <String>]
    [-AdminUsername <String>]
    [-ComputerName <String>]
    [-EnableTpm]
    [-SshPublicKey <String[]>]
    [-StoragePathId <String>]
    [-StoragePathName <String>]
    [-StoragePathResourceGroup <String>]
    [-SecureBootEnabled]
    [-EnableAutomaticUpdate]
    [-TimeZone <String>]
    [-DefaultProfile <PSObject>]
    [-AsJob]
    [-NoWait]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

ByImageName

New-AzStackHCIVMVirtualMachine
    -Name <String>
    -ResourceGroupName <String>
    -Location <String>
    -CustomLocationId <String>
    -OsType <String>
    -ImageName <String>
    [-SubscriptionId <String>]
    [-DynamicMemoryMaximumMemoryInMb <Int64>]
    [-DynamicMemoryMinimumMemoryInMb <Int64>]
    [-DynamicMemoryTargetBuffer <Int32>]
    [-VmMemoryInMB <Int64>]
    [-VmProcessor <Int32>]
    [-VmSize <String>]
    [-IdentityType <String>]
    [-DisablePasswordAuthentication]
    [-ProvisionVMAgent]
    [-ProvisionVMConfigAgent]
    [-NicId <String[]>]
    [-NicName <String[]>]
    [-NicResourceGroup <String>]
    [-DataDiskId <String[]>]
    [-DataDiskName <String[]>]
    [-DataDiskResourceGroup <String>]
    [-AdminPassword <String>]
    [-AdminUsername <String>]
    [-ComputerName <String>]
    [-EnableTpm]
    [-SshPublicKey <String[]>]
    [-StoragePathId <String>]
    [-StoragePathName <String>]
    [-StoragePathResourceGroup <String>]
    [-SecureBootEnabled]
    [-EnableAutomaticUpdate]
    [-TimeZone <String>]
    [-ImageResourceGroup <String>]
    [-DefaultProfile <PSObject>]
    [-AsJob]
    [-NoWait]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

ByOsDiskId

New-AzStackHCIVMVirtualMachine
    -Name <String>
    -ResourceGroupName <String>
    -Location <String>
    -CustomLocationId <String>
    -OsType <String>
    -OSDiskId <String>
    [-SubscriptionId <String>]
    [-DynamicMemoryMaximumMemoryInMb <Int64>]
    [-DynamicMemoryMinimumMemoryInMb <Int64>]
    [-DynamicMemoryTargetBuffer <Int32>]
    [-VmMemoryInMB <Int64>]
    [-VmProcessor <Int32>]
    [-VmSize <String>]
    [-IdentityType <String>]
    [-DisablePasswordAuthentication]
    [-ProvisionVMAgent]
    [-ProvisionVMConfigAgent]
    [-NicId <String[]>]
    [-NicName <String[]>]
    [-NicResourceGroup <String>]
    [-DataDiskId <String[]>]
    [-DataDiskName <String[]>]
    [-DataDiskResourceGroup <String>]
    [-AdminPassword <String>]
    [-AdminUsername <String>]
    [-ComputerName <String>]
    [-EnableTpm]
    [-SshPublicKey <String[]>]
    [-StoragePathId <String>]
    [-StoragePathName <String>]
    [-StoragePathResourceGroup <String>]
    [-SecureBootEnabled]
    [-EnableAutomaticUpdate]
    [-TimeZone <String>]
    [-DefaultProfile <PSObject>]
    [-AsJob]
    [-NoWait]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

ByOsDiskName

New-AzStackHCIVMVirtualMachine
    -Name <String>
    -ResourceGroupName <String>
    -Location <String>
    -CustomLocationId <String>
    -OsType <String>
    -OSDiskName <String>
    [-SubscriptionId <String>]
    [-DynamicMemoryMaximumMemoryInMb <Int64>]
    [-DynamicMemoryMinimumMemoryInMb <Int64>]
    [-DynamicMemoryTargetBuffer <Int32>]
    [-VmMemoryInMB <Int64>]
    [-VmProcessor <Int32>]
    [-VmSize <String>]
    [-IdentityType <String>]
    [-DisablePasswordAuthentication]
    [-ProvisionVMAgent]
    [-ProvisionVMConfigAgent]
    [-NicId <String[]>]
    [-NicName <String[]>]
    [-NicResourceGroup <String>]
    [-DataDiskId <String[]>]
    [-DataDiskName <String[]>]
    [-DataDiskResourceGroup <String>]
    [-AdminPassword <String>]
    [-AdminUsername <String>]
    [-ComputerName <String>]
    [-EnableTpm]
    [-SshPublicKey <String[]>]
    [-StoragePathId <String>]
    [-StoragePathName <String>]
    [-StoragePathResourceGroup <String>]
    [-SecureBootEnabled]
    [-EnableAutomaticUpdate]
    [-TimeZone <String>]
    [-OSDiskResourceGroup <String>]
    [-DefaultProfile <PSObject>]
    [-AsJob]
    [-NoWait]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

Description

The operation to create or update a virtual machine. Please note some properties can be set only during virtual machine creation.

Examples

Example 1: Create a Virtual Machine with an Image.

New-AzStackHCIVMVirtualMachine -Name "testVm" -OsType "Linux"  -ImageName "testImage" -VmSize "Standard_K8S_v1"  -AdminUsername "localadmin" -ComputerName "testVm"  -ResourceGroupName "test-rg" -CustomLocationId "/subscriptions/{subscriptionID}/resourcegroups/{resourceGroupName}/providers/microsoft.extendedlocation/customlocations/{customLocationName}"  -Location "eastus"
Name            ResourceGroupName
----            -----------------
testVm          test-rg

This command creates a virtual machine from a gallery image.

Example 2: Create a Virtual Machine with a Disk.

New-AzStackHCIVMVirtualMachine -Name "testVm" -OsType "Linux" -OsDiskName "testOsDisk10" -VmSize "Standard_K8S_v1"  -AdminUsername "localadmin" -ComputerName "testVm" -ResourceGroupName "test-rg" -CustomLocationId "/subscriptions/{subscriptionID}/resourcegroups/{resourceGroupName}/providers/microsoft.extendedlocation/customlocations/{customLocationName}" -Location "eastus"
Name            ResourceGroupName
----            -----------------
testVm          test-rg

This command creates a virtual machine from a disk.

Parameters

-AdminPassword

AdminPassword - admin password

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-AdminUsername

AdminUsername - admin username

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-AsJob

Run the command as a job

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-ComputerName

ComputerName - name of the computer

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-Confirm

Prompts you for confirmation before running the cmdlet.

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False
Aliases:cf

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-CustomLocationId

The name of the extended location.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-DataDiskId

Data Disks - List of data disks to be attached to the virtual machine in id format.

Parameter properties

Type:

String[]

Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-DataDiskName

Data Disks - List of data disks to be attached to the virtual machine in name format .

Parameter properties

Type:

String[]

Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-DataDiskResourceGroup

Data Disks - Resource Group of Data Disks.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-DefaultProfile

The credentials, account, tenant, and subscription used for communication with Azure.

Parameter properties

Type:PSObject
Default value:None
Supports wildcards:False
DontShow:False
Aliases:AzureRMContext, AzureCredential

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-DisablePasswordAuthentication

DisablePasswordAuthentication - whether password authentication should be disabled

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-DynamicMemoryMaximumMemoryInMb

Maximum Dynamic Memory

Parameter properties

Type:Int64
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-DynamicMemoryMinimumMemoryInMb

Minimum Dynamic Memory

Parameter properties

Type:Int64
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-DynamicMemoryTargetBuffer

Defines the amount of extra memory that should be reserved for a virtual machine at runtime, as a percentage of the total memory that the virtual machine is thought to need. This only applies to virtual systems with dynamic memory enabled. This property can be in the range of 5 to 2000.

Parameter properties

Type:Int32
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-EnableAutomaticUpdate

Specifies Whether to EnableAutomaticUpdates on the machine.

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-EnableTpm

Used to indicate whether or not to enable TPM

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-IdentityType

The identity type.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-ImageId

Resource ID of the image to create the VM with.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

ByImageId
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-ImageName

Name of the image to create the VM with.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

ByImageName
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-ImageResourceGroup

Resource group of the image to create the VM from.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

ByImageName
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-Location

The geo-location where the resource lives

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-Name

Name of the virtual machine

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False
Aliases:VirtualMachineName

Parameter sets

(All)
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-NicId

NetworkInterfaces - list of network interfaces to be attached to the virtual machine in ARM Id format.

Parameter properties

Type:

String[]

Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-NicName

NetworkInterfaces - list of network interfaces to be attached to the virtual machine in name format.

Parameter properties

Type:

String[]

Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-NicResourceGroup

NetworkInterfaces - Resource Group of Network Interfaces.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-NoWait

Run the command asynchronously

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-OSDiskId

Resource ID of the OS disk

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

ByOsDiskId
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-OSDiskName

Name of the OS disk

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

ByOsDiskName
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-OSDiskResourceGroup

Resource Group of the OS disk

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

ByOsDiskName
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-OsType

OsType - string specifying whether the OS is Linux or Windows

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-ProvisionVMAgent

Used to indicate whether Arc for Servers agent onboarding should be triggered during the virtual machine creation process. VM Agent is provisioned by default. Please pass -ProvisionVMAgent:$false to disable.

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-ProvisionVMConfigAgent

Indicates whether virtual machine configuration agent should be provisioned on the virtual machine. When this property is not specified, default behavior is to set it to true. VM Config Agent is provisioned by default. Please pass -ProvisionVMConfigAgent:$false to disable.

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-ResourceGroupName

The name of the resource group. The name is case insensitive.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-SecureBootEnabled

Specifies whether secure boot should be enabled on the virtual machine.

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-SshPublicKey

PublicKeys - The list of SSH public keys used to authenticate with VMs

Parameter properties

Type:

String[]

Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-StoragePathId

Id of the storage container that hosts the VM configuration file

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-StoragePathName

Name of the storage container that hosts the VM configuration file

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-StoragePathResourceGroup

Storage Container resource group. The resource group of the virtual machine will be used if this value is not provided.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-SubscriptionId

The ID of the target subscription.

Parameter properties

Type:String
Default value:(Get-AzContext).Subscription.Id
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-TimeZone

TimeZone for the virtual machine

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-VmMemoryInMB

RAM in MB for the virtual machine

Parameter properties

Type:Int64
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-VmProcessor

Number of processors for the virtual machine

Parameter properties

Type:Int32
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-VmSize

Size of the VM. Can be a Predefined size or Custom. Possible Predefined Sizes include - Custom,Standard_A2_v2,Standard_A4_v2,Standard_D16s_v3,Standard_D2s_v3,Standard_D32s_v3,Standard_D4s_v3,Standard_D8s_v3,Standard_DS13_v2,Standard_DS2_v2,Standard_DS3_v2,Standard_DS4_v2,Standard_DS5_v2,Standard_K8S2_v1,Standard_K8S3_v1,Standard_K8S4_v1,Standard_K8S5_v1,Standard_K8S_v1,Standard_NK12,Standard_NK6,Standard_NV12, StandardNv6

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet is not run.

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False
Aliases:wi

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

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.

Outputs

IVirtualMachineInstance