Set-VM

Set-VM

Configures a virtual machine.

語法

Parameter Set: Name
Set-VM [-Name] <String[]> [-AllowUnverifiedPaths] [-AutomaticCriticalErrorAction <Nullable [Microsoft.HyperV.PowerShell.CriticalErrorAction]> ] [-AutomaticCriticalErrorActionTimeout <Nullable [System.Int32]> ] [-AutomaticStartAction <StartAction]> ] [-AutomaticStartDelay <Int32]> ] [-AutomaticStopAction <StopAction]> ] [-CheckpointType <Nullable [Microsoft.HyperV.PowerShell.CheckpointType]> ] [-CimSession <Microsoft.Management.Infrastructure.CimSession[]> ] [-ComputerName <String[]> ] [-Credential <System.Management.Automation.PSCredential[]> ] [-DynamicMemory] [-GuestControlledCacheTypes <System.Boolean> ] [-LockOnDisconnect <Nullable [Microsoft.HyperV.PowerShell.OnOffState]> ] [-MemoryMaximumBytes <Int64]> ] [-MemoryMinimumBytes <Int64]> ] [-MemoryStartupBytes <Int64]> ] [-NewVMName <String> ] [-Notes <String> ] [-Passthru] [-ProcessorCount <Int64]> ] [-SmartPagingFilePath <String> ] [-SnapshotFileLocation <String> ] [-StaticMemory] [-Confirm] [-WhatIf] [ <CommonParameters>]

Parameter Set: VMObject
Set-VM [-VM] <VirtualMachine[]> [-AllowUnverifiedPaths] [-AutomaticCriticalErrorAction <Nullable [Microsoft.HyperV.PowerShell.CriticalErrorAction]> ] [-AutomaticCriticalErrorActionTimeout <Nullable [System.Int32]> ] [-AutomaticStartAction <StartAction]> ] [-AutomaticStartDelay <Int32]> ] [-AutomaticStopAction <StopAction]> ] [-CheckpointType <Nullable [Microsoft.HyperV.PowerShell.CheckpointType]> ] [-DynamicMemory] [-GuestControlledCacheTypes <System.Boolean> ] [-LockOnDisconnect <Nullable [Microsoft.HyperV.PowerShell.OnOffState]> ] [-MemoryMaximumBytes <Int64]> ] [-MemoryMinimumBytes <Int64]> ] [-MemoryStartupBytes <Int64]> ] [-NewVMName <String> ] [-Notes <String> ] [-Passthru] [-ProcessorCount <Int64]> ] [-SmartPagingFilePath <String> ] [-SnapshotFileLocation <String> ] [-StaticMemory] [-Confirm] [-WhatIf] [ <CommonParameters>]

詳細描述

The Set-VM cmdlet configures a virtual machine.

參數

-AutomaticCriticalErrorAction<Nullable [Microsoft.HyperV.PowerShell.CriticalErrorAction]>

Specifies the action to take when the VM encounters a critical error, and exceeds the timeout duration specified by the AutomaticCriticalErrorActionTimeout cmdlet. 這個參數可接受的值如下: Pause and None.

別名

none

必要項?

false

位置?

named

預設值

none

接受管線輸入?

false

接受萬用字元?

false

-AutomaticCriticalErrorActionTimeout<Nullable [System.Int32]>

Specifies the amount of time, in minutes, to wait in critical pause before powering off the virtual machine.

別名

none

必要項?

false

位置?

named

預設值

none

接受管線輸入?

false

接受萬用字元?

false

-AutomaticStartAction<StartAction]>

Specifies the action the virtual machine is to take upon start. Allowed values are Nothing, StartIfRunning, and Start.

別名

none

必要項?

false

位置?

named

預設值

none

接受管線輸入?

false

接受萬用字元?

false

-AutomaticStartDelay<Int32]>

Specifies the number of seconds by which the virtual machine’s start should be delayed.

別名

none

必要項?

false

位置?

named

預設值

none

接受管線輸入?

false

接受萬用字元?

false

-AutomaticStopAction<StopAction]>

Specifies the action the virtual machine is to take when the virtual machine host shuts down. Allowed values are TurnOff, Save, and ShutDown.

別名

none

必要項?

false

位置?

named

預設值

none

接受管線輸入?

false

接受萬用字元?

false

-CheckpointType<Nullable [Microsoft.HyperV.PowerShell.CheckpointType]>

Allows you to configure the type of checkpoints created by Hyper-V. 這個參數可接受的值如下:

-- Disabled. Block creation of checkpoints.
-- Standard. Create standard checkpoints.
-- Production. Create production checkpoints if supported by guest operating system. Otherwise, create standard checkpoints.
-- ProductionOnly. Create production checkpoints if supported by guest operating system. Otherwise, the operation fails.

別名

none

必要項?

false

位置?

named

預設值

none

接受管線輸入?

false

接受萬用字元?

false

-CimSession<Microsoft.Management.Infrastructure.CimSession[]>

在遠端工作階段或遠端電腦上執行 Cmdlet。輸入電腦名稱或工作階段物件,例如 New-CimSessionGet-CimSession Cmdlet 的輸出。預設為本機電腦上目前的工作階段。

別名

none

必要項?

false

位置?

named

預設值

none

接受管線輸入?

false

接受萬用字元?

false

-ComputerName<String[]>

Specifies one or more Hyper-V hosts on which the virtual machine is to be configured. 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.

別名

none

必要項?

false

位置?

named

預設值

none

接受管線輸入?

false

接受萬用字元?

false

-Credential<System.Management.Automation.PSCredential[]>

Specifies one or more user accounts that have permission to perform this action. The default is the current user.

別名

none

必要項?

false

位置?

named

預設值

none

接受管線輸入?

false

接受萬用字元?

false

-DynamicMemory

Specifies that the virtual machine is to be configured to use dynamic memory.

別名

none

必要項?

false

位置?

named

預設值

none

接受管線輸入?

false

接受萬用字元?

false

-GuestControlledCacheTypes<System.Boolean>

Specifies whether this virtual machine uses guest controlled cache types.

別名

none

必要項?

false

位置?

named

預設值

none

接受管線輸入?

false

接受萬用字元?

false

-LockOnDisconnect<Nullable [Microsoft.HyperV.PowerShell.OnOffState]>

Specifies whether virtual machine connection in basic mode locks the console after a user disconnects.

別名

none

必要項?

false

位置?

named

預設值

none

接受管線輸入?

false

接受萬用字元?

false

-MemoryMaximumBytes<Int64]>

Specifies the maximum amount of memory that the virtual machine is to be allocated. (Applies only to virtual machines using dynamic memory.)

別名

none

必要項?

false

位置?

named

預設值

none

接受管線輸入?

false

接受萬用字元?

false

-MemoryMinimumBytes<Int64]>

Specifies the minimum amount of memory that the virtual machine is to be allocated. (Applies only to virtual machines using dynamic memory.)

別名

none

必要項?

false

位置?

named

預設值

none

接受管線輸入?

false

接受萬用字元?

false

-MemoryStartupBytes<Int64]>

Specifies the amount of memory that the virtual machine is to be allocated upon startup. (If the virtual machine does not use dynamic memory, then this is the static amount of memory to be allocated.)

別名

none

必要項?

false

位置?

named

預設值

none

接受管線輸入?

false

接受萬用字元?

false

-Name<String[]>

Specifies the name of the virtual machine to be configured.

別名

VMName

必要項?

true

位置?

1

預設值

none

接受管線輸入?

True (ByValue)

接受萬用字元?

false

-NewVMName<String>

Specifies the name to which the virtual machine is to be renamed.

別名

none

必要項?

false

位置?

named

預設值

none

接受管線輸入?

false

接受萬用字元?

false

-Passthru

Specifies that an object is to be passed through to the pipeline representing the virtual machine to be configured.

別名

none

必要項?

false

位置?

named

預設值

none

接受管線輸入?

false

接受萬用字元?

false

-ProcessorCount<Int64]>

Specifies the number of virtual processors for the virtual machine.

別名

none

必要項?

false

位置?

named

預設值

none

接受管線輸入?

false

接受萬用字元?

false

-SnapshotFileLocation<String>

Specifies the folder in which the virtual machine is to store its snapshot files.

別名

none

必要項?

false

位置?

named

預設值

none

接受管線輸入?

false

接受萬用字元?

false

-StaticMemory

This cmdlet configures the virtual machine to use static memory. Specify the amount of static memory to allocate by using the MemoryStartupBytes parameter.

別名

none

必要項?

false

位置?

named

預設值

none

接受管線輸入?

false

接受萬用字元?

false

-VM<VirtualMachine[]>

Specifies the virtual machine to be configured.

別名

none

必要項?

true

位置?

1

預設值

none

接受管線輸入?

True (ByValue)

接受萬用字元?

false

-AllowUnverifiedPaths

Specifies that no error is to be thrown if the specified path is not verified as accessible by the cluster. This parameter is applicable to clustered virtual machines.

別名

none

必要項?

false

位置?

named

預設值

none

接受管線輸入?

false

接受萬用字元?

false

-SmartPagingFilePath<String>

Specifies the folder in which the Smart Paging file is to be stored.

別名

none

必要項?

false

位置?

named

預設值

none

接受管線輸入?

false

接受萬用字元?

false

-Notes<String>

Specifies notes to be associated with the virtual machine.

別名

none

必要項?

false

位置?

named

預設值

none

接受管線輸入?

false

接受萬用字元?

false

-Confirm

在執行指令程式之前提示您確認。

必要項?

false

位置?

named

預設值

false

接受管線輸入?

false

接受萬用字元?

false

-WhatIf

示範當執行指令程式時會發生什麼事情。此指令程式並未執行。

必要項?

false

位置?

named

預設值

false

接受管線輸入?

false

接受萬用字元?

false

<CommonParameters>

這個指令程式支援一般參數:-Verbose、-Debug、-ErrorAction、-ErrorVariable、-OutBuffer 和 -OutVariable。如需詳細資訊,請參閱 about_CommonParameters (https://go.microsoft.com/fwlink/p/?LinkID=113216)。

輸入

輸入類型是可透過管道傳送至指令程式的物件類型。

輸出

輸出類型是指令程式所發出的物件類型。

  • None by default; Microsoft.HyperV.PowerShell.VirtualMachine if –PassThru is specified.

範例

Example 1

Configures virtual machine TestVM to shut down when the Hyper-V host shuts down.

PS C:\> Set-VM –Name TestVM –AutomaticStopAction Shutdown

Example 2

Stops virtual machine TestVM, sets it to use dynamic memory, sets its maximum amount of memory to 2GB, sets it to use 2 virtual processors, and starts it.

PS C:\> Stop-VM -Name TestVM -Passthru | Set-VM -ProcessorCount 2 -DynamicMemory -MemoryMaximumBytes 2GB -Passthru | Start-VM