Stop-SCVirtualMachine
Stops virtual machines managed by VMM.
Syntax
Stop-SCVirtualMachine
[-VM] <VM>
[-Shutdown]
[-RunAsynchronously]
[-PROTipID <Guid>]
[-JobVariable <String>]
[-OnBehalfOfUser <String>]
[-OnBehalfOfUserRole <UserRole>]
[<CommonParameters>]
Stop-SCVirtualMachine
[-VM] <VM>
[-SaveState]
[-RunAsynchronously]
[-PROTipID <Guid>]
[-JobVariable <String>]
[-OnBehalfOfUser <String>]
[-OnBehalfOfUserRole <UserRole>]
[<CommonParameters>]
Stop-SCVirtualMachine
[-VM] <VM>
[-DiscardSavedState]
[-RunAsynchronously]
[-PROTipID <Guid>]
[-JobVariable <String>]
[-OnBehalfOfUser <String>]
[-OnBehalfOfUserRole <UserRole>]
[<CommonParameters>]
Stop-SCVirtualMachine
[-VM] <VM>
[-Force]
[-RunAsynchronously]
[-PROTipID <Guid>]
[-JobVariable <String>]
[-OnBehalfOfUser <String>]
[-OnBehalfOfUserRole <UserRole>]
[<CommonParameters>]
Description
The Stop-SCVirtualMachine cmdlet stops one or more running virtual machines on hosts managed by Virtual Machine Manager (VMM) and returns the virtual machine object in a stopped state.
This cmdlet stops a virtual machine just like shutting down the operating system on a computer. If you specify the Force parameter, this cmdlet stops a virtual machine just like turning off a computer.
To resume a stopped virtual machine, use the Start-SCVirtualMachine cmdlet.
Examples
Example 1: Stop a specified virtual machine
PS C:\> $VM = Get-SCVirtualMachine -Name "VM01"
PS C:\> Stop-SCVirtualMachine -VM $VM
The first command gets the virtual machine object named VM01, and then stores that object in the $VM variable.
The second command stops the virtual machine stored in $VM, and displays information about the stopped object.
Example 2: Stop multiple virtual machines
PS C:\> $VMs = Get-SCVirtualMachine | where { $_.Name -match "VM" -and $_.Status -eq "Running" }
PS C:\> $VMs | Stop-SCVirtualMachine
The first command gets all virtual machine objects whose name contains the string VMM and whose current status is Running. The command then stores those objects in the $VMs array.
The second command passes each virtual machine object stored in $VMs to the current cmdlet, which stops each virtual machine. The command displays information about the stopped virtual machines.
Parameters
-DiscardSavedState
Indicates that this cmdlet deletes the saved state associated with a virtual machine.
Type: | SwitchParameter |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-Force
Indicates that this cmdlet stops a virtual machine just like turning off a computer.
Type: | SwitchParameter |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-JobVariable
Specifies a variable in which job progress is tracked and stored.
Type: | String |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-OnBehalfOfUser
Specifies a user name. This cmdlet operates on behalf of the user that this parameter specifies.
Type: | String |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-OnBehalfOfUserRole
Specifies a user role. To obtain a user role, use the Get-SCUserRole cmdlet. This cmdlet operates on behalf of the user role that this parameter specifies.
Type: | UserRole |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-PROTipID
Specifies the ID of the Performance and Resource Optimization tip (PRO tip) that triggered this action. This parameter lets you audit PRO tips.
Type: | Guid |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-RunAsynchronously
Indicates that the job runs asynchronously so that control returns to the command shell immediately.
Type: | SwitchParameter |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-SaveState
Indicates that this cmdlet saves the state of a virtual machine.
Type: | SwitchParameter |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-Shutdown
Indicates that this cmdlet shuts down a virtual machine. This cmdlet uses the operating system to shut the virtual machine down gracefully.
Type: | SwitchParameter |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-VM
Specifies a virtual machine object.
Type: | VM |
Position: | 0 |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
Accept wildcard characters: | False |
Outputs
VirtualMachine
This cmdlet returns a VirtualMachine object.
Notes
- This cmdlet requires a virtual machine object, which can be retrieved by using the Get-SCVirtualMachine cmdlet.