This command removes the virtual machine named VirtualMachine07 in the resource group ResourceGroup11.
Example 2: Remove a VM in a VMSS with the orchestration mode set to Flex.
# Get a VMSS with the orchestration mode set to Flex.
$rgname = <Resource Group Name>
$vmssName = <VMSS Name>
$vmssFlex = Get-AzVmss -ResourceGroupName $rgname -VMScaleSetName $vmssName
$vmssvms = Get-AzVmssVM -ResourceGroupName $vmssFlex.ResourceGroupName -VMScaleSetName $vmssFlex.Name
# Get the first VM's name to delete it.
$vmName = $vmssvms[0].Name
Remove-AzVM -ResourceGroupName $rgname -Name $vmName
This example shows how to delete a virtual machine within a virtual machine scale set of the orchestration mode Flex with this cmdlet.
This will not work on a virtual machine scale set of orchestration mode Uniform.
Parameters
-AsJob
Run cmdlet in the background and return a Job to track progress.
Starts the operation and returns immediately, before the operation is completed. In order to determine if the operation has successfully been completed, use some other mechanism.
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.
The source for this content can be found on GitHub, where you can also create and review issues and pull requests. For more information, see our contributor guide.