Editar

Partilhar via


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

Set-AzVM
   [-ResourceGroupName] <String>
   [-Name] <String>
   [-Generalized]
   [-AsJob]
   [-DefaultProfile <IAzureContextContainer>]
   [<CommonParameters>]
Set-AzVM
   [-ResourceGroupName] <String>
   [-Name] <String>
   [-Redeploy]
   [-AsJob]
   [-NoWait]
   [-DefaultProfile <IAzureContextContainer>]
   [<CommonParameters>]
Set-AzVM
   [-ResourceGroupName] <String>
   [-Name] <String>
   [-Reapply]
   [-AsJob]
   [-NoWait]
   [-DefaultProfile <IAzureContextContainer>]
   [<CommonParameters>]
Set-AzVM
   [-ResourceGroupName] <String>
   [-Name] <String>
   [-SimulateEviction]
   [-AsJob]
   [-DefaultProfile <IAzureContextContainer>]
   [<CommonParameters>]
Set-AzVM
   [-Id] <String>
   [-Generalized]
   [-AsJob]
   [-DefaultProfile <IAzureContextContainer>]
   [<CommonParameters>]
Set-AzVM
   [-Id] <String>
   [-Redeploy]
   [-AsJob]
   [-NoWait]
   [-DefaultProfile <IAzureContextContainer>]
   [<CommonParameters>]
Set-AzVM
   [-Id] <String>
   [-Reapply]
   [-AsJob]
   [-NoWait]
   [-DefaultProfile <IAzureContextContainer>]
   [<CommonParameters>]
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.

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-DefaultProfile

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

Type:IAzureContextContainer
Aliases:AzContext, AzureRmContext, AzureCredential
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Generalized

Indicates that this cmdlet marks a virtual machine as generalized.

Type:SwitchParameter
Position:Named
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-Id

Specifies the Resource ID of the virtual machine.

Type:String
Position:0
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-Name

Specifies the name of the virtual machine on which this cmdlet operates.

Type:String
Position:1
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters: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.

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Reapply

To reapply virtual machine.

Type:SwitchParameter
Position:Named
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters: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.

Type:SwitchParameter
Position:Named
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-ResourceGroupName

Specifies the name of the resource group of the virtual machine.

Type:String
Position:0
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-SimulateEviction

Indicates that this cmdlet simulates the eviction of spot virtual machine. The eviction will occur within 30 minutes of calling the API.

Type:SwitchParameter
Position:Named
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

Inputs

String

Outputs

PSComputeLongRunningOperation

PSAzureOperationResponse