Set-VM

Configures a virtual machine.

Syntax

Set-VM
   [-ComputerName <String[]>]
   [-Name] <String[]>
   [-ProcessorCount <Int64>]
   [-DynamicMemory]
   [-StaticMemory]
   [-MemoryMinimumBytes <Int64>]
   [-MemoryMaximumBytes <Int64>]
   [-MemoryStartupBytes <Int64>]
   [-SmartPagingFilePath <String>]
   [-AutomaticStartAction <StartAction>]
   [-AutomaticStopAction <StopAction>]
   [-AutomaticStartDelay <Int32>]
   [-Notes <String>]
   [-NewVMName <String>]
   [-SnapshotFileLocation <String>]
   [-Passthru]
   [-AllowUnverifiedPaths]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]
Set-VM
   [-ProcessorCount <Int64>]
   [-DynamicMemory]
   [-StaticMemory]
   [-MemoryMinimumBytes <Int64>]
   [-MemoryMaximumBytes <Int64>]
   [-MemoryStartupBytes <Int64>]
   [-SmartPagingFilePath <String>]
   [-AutomaticStartAction <StartAction>]
   [-AutomaticStopAction <StopAction>]
   [-AutomaticStartDelay <Int32>]
   [-Notes <String>]
   [-NewVMName <String>]
   [-SnapshotFileLocation <String>]
   [-Passthru]
   [-AllowUnverifiedPaths]
   [-VM] <VirtualMachine[]>
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]

Description

The Set-VM cmdlet configures a virtual machine.

Examples

Example 1

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

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

Example 2

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

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.

Parameters

-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.

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

-AutomaticStartAction

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

Type:StartAction
Accepted values:Nothing, StartIfRunning, Start
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-AutomaticStartDelay

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

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

-AutomaticStopAction

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

Type:StopAction
Accepted values:TurnOff, Save, ShutDown
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-ComputerName

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.

Type:String[]
Position:Named
Default value:.
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Confirm

Prompts you for confirmation before running the cmdlet.

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

-DynamicMemory

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

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

-MemoryMaximumBytes

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

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

-MemoryMinimumBytes

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

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

-MemoryStartupBytes

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.)

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

-Name

Specifies the name of the virtual machine to be configured.

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

-NewVMName

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

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

-Notes

Specifies notes to be associated with the virtual machine.

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

-Passthru

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

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

-ProcessorCount

Specifies the number of virtual processors for the virtual machine.

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

-SmartPagingFilePath

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

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

-SnapshotFileLocation

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

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

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

-VM

Specifies the virtual machine to be configured.

Type:VirtualMachine[]
Position:0
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-WhatIf

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

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

Outputs

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