Restart-AzVM
Restarts an Azure virtual machine.
Restart-AzVM -ResourceGroupName <String> -Name <String> [-Force] [-AsJob] [-WhatIf] [-Confirm] [<CommonParameters>]
SYNTAX
Use the syntax below to restart an Azure virtual machine.
Restart-AzVM [-ResourceGroupName] <String> [-Name] <String> [-Force] [-AsJob] [-WhatIf] [-Confirm] [<CommonParameters>]
DESCRIPTION
The Restart-AzVM cmdlet restarts an Azure virtual machine.
This cmdlet can be used to restart a virtual machine that is in a running state. It performs a soft restart, similar to restarting a physical machine from within the operating system. If the virtual machine is in a stopped state, this cmdlet will start it.
PARAMETERS
| Name | Type | Description |
|---|---|---|
| -ResourceGroupName | System.String | Specifies the name of the resource group that contains the virtual machine. |
| -Name | System.String | Specifies the name of the virtual machine to restart. |
| -Force | System.Management.Automation.SwitchParameter | Forces the command to run without asking for user confirmation. |
| -AsJob | System.Management.Automation.SwitchParameter | Runs the cmdlet as a background job. Use this parameter to run the cmdlet that returns immediately and all the work is done in the background. |
| -WhatIf | System.Management.Automation.SwitchParameter | Shows what would happen if the cmdlet runs. The cmdlet is not run. |
| -Confirm | System.Management.Automation.SwitchParameter | Prompts you for confirmation before running the cmdlet. |
EXAMPLES
Example 1: Restart a virtual machine
PS C:\> Restart-AzVM -ResourceGroupName "ResourceGroup11" -Name "VirtualMachine07"
This command restarts the virtual machine named VirtualMachine07 in the resource group named ResourceGroup11.
Example 2: Restart a virtual machine without confirmation
PS C:\> Restart-AzVM -ResourceGroupName "ResourceGroup11" -Name "VirtualMachine07" -Force
This command restarts the virtual machine named VirtualMachine07 in the resource group named ResourceGroup11 without prompting for confirmation.
Example 3: Restart a virtual machine as a background job
PS C:\> Restart-AzVM -ResourceGroupName "ResourceGroup11" -Name "VirtualMachine07" -AsJob
This command restarts the virtual machine named VirtualMachine07 in the resource group named ResourceGroup11 as a background job.
INPUTS
Microsoft.Azure.Commands.Compute.Models.PSVirtualMachine
System.String
OUTPUTS
Microsoft.Azure.Commands.Compute.Models.PSOperationStatusResponse