Set-AzVM
This cmdlet can be used to do the followings: reapply or redeploy a virtual machine, mark a virtual machine as generalized, simulate eviction to a spot virtual machine.
Syntax
GeneralizeResourceGroupNameParameterSetName (Default)
Set-AzVM
[-ResourceGroupName] <String>
[-Name] <String>
[-Generalized]
[-AsJob]
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
RedeployResourceGroupNameParameterSetName
Set-AzVM
[-ResourceGroupName] <String>
[-Name] <String>
[-Redeploy]
[-AsJob]
[-NoWait]
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
ReapplyResourceGroupNameParameterSetName
Set-AzVM
[-ResourceGroupName] <String>
[-Name] <String>
[-Reapply]
[-AsJob]
[-NoWait]
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
SimulateEvictionResourceGroupNameParameterSetName
Set-AzVM
[-ResourceGroupName] <String>
[-Name] <String>
[-SimulateEviction]
[-AsJob]
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
GeneralizeIdParameterSetName
Set-AzVM
[-Id] <String>
[-Generalized]
[-AsJob]
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
RedeployIdParameterSetName
Set-AzVM
[-Id] <String>
[-Redeploy]
[-AsJob]
[-NoWait]
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
ReapplyIdParameterSetName
Set-AzVM
[-Id] <String>
[-Reapply]
[-AsJob]
[-NoWait]
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
SimulateEvictionIdParameterSetName
Set-AzVM
[-Id] <String>
[-SimulateEviction]
[-AsJob]
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
Description
The Set-AzVM cmdlet can be used to redeploy or reapply a virtual machine. It can also be used to mark a virtual machine as generalized or simulate eviction to a spot virtual machine.
Before you mark a virtual machine as generalized, log on to the virtual machine and use Sysprep to prepare the hard disk. See here for more information.
Examples
Example 1: Mark a virtual machine as generalized
Set-AzVM -ResourceGroupName "ResourceGroup11" -Name "VirtualMachine07" -Generalized
This command marks the virtual machine named "VirtualMachine07" as generalized.
Example 2: Simulate eviction to a spot virtual machine using resource ID
$vm = Get-AzVM -ResourceGroupName "ResourceGroup11" -Name "VirtualMachine07"
Set-AzVM -Id $vm.id -SimulateEviction
This command simulates eviction to the virtual machine named "VirtualMachine07" using the resource ID.
Example 3: Reapply a virtual machine
Set-AzVM -ResourceGroupName "ResourceGroup11" -Name "VirtualMachine07" -Reapply
This command reapplies the virtual machine named "VirtualMachine07".
Example 4: Redeploy a virtual machine using resource ID
$vm = Get-AzVM -ResourceGroupName "ResourceGroup11" -Name "VirtualMachine07"
Set-AzVM -Id $vm.id -Redeploy
This command deploys the virtual machine named "VirtualMachine07" using the resource ID.
Parameters
-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
(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: IAzureContextContainer
Default value: None
Supports wildcards: False
DontShow: False
Aliases: AzContext, 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
-Generalized
Indicates that this cmdlet marks a virtual machine as generalized.
Parameter properties
Type: SwitchParameter
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
GeneralizeResourceGroupNameParameterSetName
Position: Named
Mandatory: True
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
GeneralizeIdParameterSetName
Position: Named
Mandatory: True
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-Id
Specifies the Resource ID of the virtual machine.
Parameter properties
Type: String
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
GeneralizeIdParameterSetName
Position: 0
Mandatory: True
Value from pipeline: False
Value from pipeline by property name: True
Value from remaining arguments: False
RedeployIdParameterSetName
Position: 0
Mandatory: True
Value from pipeline: False
Value from pipeline by property name: True
Value from remaining arguments: False
ReapplyIdParameterSetName
Position: 0
Mandatory: True
Value from pipeline: False
Value from pipeline by property name: True
Value from remaining arguments: False
SimulateEvictionIdParameterSetName
Position: 0
Mandatory: True
Value from pipeline: False
Value from pipeline by property name: True
Value from remaining arguments: False
-Name
Specifies the name of the virtual machine on which this cmdlet operates.
Parameter properties
Type: String
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
GeneralizeResourceGroupNameParameterSetName
Position: 1
Mandatory: True
Value from pipeline: False
Value from pipeline by property name: True
Value from remaining arguments: False
RedeployResourceGroupNameParameterSetName
Position: 1
Mandatory: True
Value from pipeline: False
Value from pipeline by property name: True
Value from remaining arguments: False
ReapplyResourceGroupNameParameterSetName
Position: 1
Mandatory: True
Value from pipeline: False
Value from pipeline by property name: True
Value from remaining arguments: False
SimulateEvictionResourceGroupNameParameterSetName
Position: 1
Mandatory: True
Value from pipeline: False
Value from pipeline by property name: True
Value from remaining arguments: False
-NoWait
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.
Parameter properties
Type: SwitchParameter
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
RedeployResourceGroupNameParameterSetName
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
ReapplyResourceGroupNameParameterSetName
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
RedeployIdParameterSetName
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
ReapplyIdParameterSetName
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-Reapply
To reapply virtual machine.
Parameter properties
Type: SwitchParameter
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
ReapplyResourceGroupNameParameterSetName
Position: Named
Mandatory: True
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
ReapplyIdParameterSetName
Position: Named
Mandatory: True
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-Redeploy
Indicates that this cmdlet manually redeploys the virtual machine to a different Azure host to fix any problems.
If you redeploy a virtual machine, it restarts, which results in the loss of ephemeral drive data.
Parameter properties
Type: SwitchParameter
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
RedeployResourceGroupNameParameterSetName
Position: Named
Mandatory: True
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
RedeployIdParameterSetName
Position: Named
Mandatory: True
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-ResourceGroupName
Specifies the name of the resource group of the virtual machine.
Parameter properties
Type: String
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
GeneralizeResourceGroupNameParameterSetName
Position: 0
Mandatory: True
Value from pipeline: False
Value from pipeline by property name: True
Value from remaining arguments: False
RedeployResourceGroupNameParameterSetName
Position: 0
Mandatory: True
Value from pipeline: False
Value from pipeline by property name: True
Value from remaining arguments: False
ReapplyResourceGroupNameParameterSetName
Position: 0
Mandatory: True
Value from pipeline: False
Value from pipeline by property name: True
Value from remaining arguments: False
SimulateEvictionResourceGroupNameParameterSetName
Position: 0
Mandatory: True
Value from pipeline: False
Value from pipeline by property name: True
Value from remaining arguments: False
-SimulateEviction
Indicates that this cmdlet simulates the eviction of spot virtual machine.
The eviction will occur within 30 minutes of calling the API.
Parameter properties
Type: SwitchParameter
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
SimulateEvictionResourceGroupNameParameterSetName
Position: Named
Mandatory: True
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
SimulateEvictionIdParameterSetName
Position: Named
Mandatory: True
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