Stop-VM

Stop-VM

Shuts down, turns off, or saves a virtual machine.

Syntax

Parameter Set: Name
Stop-VM [-Name] <String[]> [-AsJob] [-ComputerName <String[]> ] [-Force] [-Passthru] [-Save] [-TurnOff] [-Confirm] [-WhatIf] [ <CommonParameters>]

Parameter Set: VMObject
Stop-VM [-VM] <VirtualMachine[]> [-AsJob] [-Force] [-Passthru] [-Save] [-TurnOff] [-Confirm] [-WhatIf] [ <CommonParameters>]

Detailed Description

The Stop-VM cmdlet shuts down, turns off, or saves a virtual machine.

Parameters

-AsJob

Specifies that the cmdlet is to be run as a background job.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-ComputerName<String[]>

Specifies one or more Hyper-V hosts on which a virtual machine is to be shut down. NetBIOS names, IP addresses, and fully-qualified domain names are allowable. The default is the local computer — use “localhost” or a dot (“.”) to specify the local computer explicitly.

Aliases

none

Required?

false

Position?

named

Default Value

.

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Force

Specifies that the shutdown of the virtual machine is to be forced. If the virtual machine has applications with unsaved data, the virtual machine has five minutes to save data and shut down. If the virtual machine is locked, it is shut down immediately.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Name<String[]>

Specifies the name of the virtual machine to be shut down.

Aliases

none

Required?

true

Position?

1

Default Value

none

Accept Pipeline Input?

true (ByValue)

Accept Wildcard Characters?

true

-Passthru

Specifies that a Microsoft.Virtualization.Powershell.VirtualMachine object is to be passed through to the pipeline representing the virtual machine to be shut down.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Save

Specifies that the virtual machine is to be saved.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-TurnOff

Specifies that the virtual machine is to be turned off.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-VM<VirtualMachine[]>

Specifies the virtual machine to be shut down.

Aliases

none

Required?

true

Position?

1

Default Value

none

Accept Pipeline Input?

true (ByValue)

Accept Wildcard Characters?

false

-Confirm

Prompts you for confirmation before running the cmdlet.

Required?

false

Position?

named

Default Value

false

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-WhatIf

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

Required?

false

Position?

named

Default Value

false

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

<CommonParameters>

This cmdlet supports the common parameters: -Verbose, -Debug, -ErrorAction, -ErrorVariable, -OutBuffer, and -OutVariable. For more information, see    about_CommonParameters (https://go.microsoft.com/fwlink/p/?LinkID=113216).

Inputs

The input type is the type of the objects that you can pipe to the cmdlet.

Outputs

The output type is the type of the objects that the cmdlet emits.

  • None by default; Microsoft.Virtualization.Powershell.VirtualMachine if –PassThru is specified.

Examples

Example 1

Shuts down virtual machine TestVM through the guest operating system.

PS C:\> Stop-VM –Name TestVM

Example 2

Shuts down virtual machine TestVM through the guest operating system, regardless of any unsaved application data. Hyper-V gives the guest five minutes to save data, then forces a shutdown. This shutdown can result in loss of unsaved data.

PS C:\> Stop-VM –Name VM1 -Force

Example 3

Turns off virtual machine TestVM. This operation is equivalent to disconnecting the power from the virtual machine, and can result in loss of unsaved data.

PS C:\> Stop-VM –Name TestVM –TurnOff