vSphere PowerCLI Reference

Set-VM

Synopsis

Changes the configuration of the virtual machine.

Syntax

Set-VM [-VM] <VirtualMachine[]> [-Name <String>] [-Version <VMVersion>] [-MemoryMB <Int64>] [-MemoryGB <Decimal>] [-NumCpu <Int32>] [-GuestId <String>] [-AlternateGuestName <String>] [-OSCustomizationSpec <OSCustomizationSpec>] [-HARestartPriority <HARestartPriority>] [-HAIsolationResponse <HAIsolationResponse>] [-DrsAutomationLevel <DrsAutomationLevel>] [-Server <VIServer[]>] [-RunAsync] [-VMSwapFilePolicy <VMSwapfilePolicy>] [-Notes <String>] [-WhatIf] [-Confirm] [<CommonParameters>]
Set-VM [-VM] <VirtualMachine[]> [-Name <String>] [-Snapshot <Snapshot>] [-OSCustomizationSpec <OSCustomizationSpec>] [-HARestartPriority <HARestartPriority>] [-HAIsolationResponse <HAIsolationResponse>] [-DrsAutomationLevel <DrsAutomationLevel>] [-Server <VIServer[]>] [-RunAsync] [-VMSwapFilePolicy <VMSwapfilePolicy>] [-WhatIf] [-Confirm] [<CommonParameters>]
Set-VM [-VM] <VirtualMachine[]> [-Name <String>] [-Server <VIServer[]>] [-RunAsync] [-ToTemplate] [-WhatIf] [-Confirm] [<CommonParameters>]

Related Commands

Online version
Get-VM
Move-VM
New-VM
Remove-VM
Start-VM
Stop-VM
Suspend-VM

Detailed Description

Changes the configuration of the virtual machine. If the OSCustomizationSpec parameter is used, the cmdlet customizes the virtual machine according to the specification. In addition, the cmdlet allows you to revert a virtual machine to a snapshot and convert a virtual machine to a template.

Parameters

NameTypeDescriptionRequired?Pipeline InputDefault Value
VMVirtualMachine[]Specify the virtual machine you want to configure.truetrue (ByValue)
AlternateGuestNameStringSpecify the full name of the guest OS for the virtual machine if the value of the GuestID parameter is set to otherGuest or otherGuest64.falsefalse
ConfirmSwitchParameterIf the value is $true, indicates that the cmdlet asks for confirmation before running. If the value is $false, the cmdlet runs without asking for user confirmation.falsefalse$true
DrsAutomationLevelDrsAutomationLevelSpecify a DRS (Distributed Resource Scheduler) automation level. The valid values are FullyAutomated, Manual, and PartiallyAutomated, AsSpecifiedByCluster, and Disabled. Passing values to this parameter through a pipeline is deprecated and will be disabled in a future release. Specifying this parameter is only supported when the virtual machine is inside a cluster. Otherwise, an error is generated.falsefalse
GuestIdStringSpecify the guest operating system of the virtual machine. The valid values for specific ESX versions are listed in the description of the VirtualMachineGuestOsIdentifier enumeration type in the vSphere API Reference available at http://www.vmware.com/support/developer/vc-sdk/. Depending on the hardware configuration of the host, some of the guest operating systems might be inapplicable.falsefalse
HAIsolationResponseHAIsolationResponseIndicate whether the virtual machine should be powered off if a host determines that it is isolated from the rest of the compute resource. The valid values are AsSpecifiedByCluster, PowerOff, and DoNothing. Passing values to this parameter through a pipeline is deprecated and will be disabled in a future release. Specifying this parameter is only supported when the virtual machine is inside a cluster. Otherwise, an error is generated.falsefalse
HARestartPriorityHARestartPrioritySpecify the virtual machine HA restart priority. The valid values are Disabled, Low, Medium, High, and ClusterRestartPriority. VMware HA is a feature that detects failed virtual machines and automatically restarts them on alternative ESX hosts. Passing values to this parameter through a pipeline is deprecated and will be disabled in a future release. Specifying this parameter is only supported when the virtual machine is inside a cluster. Otherwise, an error is generated.falsefalse
MemoryGBDecimalSpecify the memory size in gigabytes (GB).falsefalse
MemoryMBInt64This parameter is obsolete. Use MemoryGB instead.
Specify the memory size in megabytes (MB).
falsefalse
NameStringSpecify a new name for the virtual machine.falsefalse
NotesStringProvide a description of the virtual machine. The alias of this parameter is Description.falsefalse
NumCpuInt32Specify the number of virtual CPUs.falsefalse
OSCustomizationSpecOSCustomizationSpecSpecify a customization specification you want to apply to the virtual machine. This works only in 32-bit mode.falsefalse
RunAsyncSwitchParameterIndicate that the command returns immediately without waiting for the task to complete. In this mode, the output of the cmdlet is a Task object. For more information about the -RunAsync parameter run " help About_RunAsync" in the vSphere PowerCLI console.falsefalse
ServerVIServer[]Specify the vSphere servers on which you want to run the cmdlet. If no value is given to this parameter, the command runs on the default servers. For more information about default servers, see the description of Connect-VIServer.falsefalse
SnapshotSnapshotSpecify a snapshot whose state you want to apply to the virtual machine.falsetrue (ByValue)
ToTemplateSwitchParameterIndicate that you want to convert the virtual machine to a template.falsefalse
VersionVMVersionSpecify the version to which you want to upgrade the virtual machine. The valid values are v4, v7, and v8. You cannot downgrade to an older version.falsefalse
VMSwapFilePolicyVMSwapfilePolicySpecify the swapfile placement policy. The following values are valid:

InHostDataStore - Store the swapfile in the datastore specified by the VMSwapfileDatastoreID property of the virtual machine host. If the VMSwapfileDatastoreID property is not set or indicates a datastore with insufficient free space, the swapfile is stored in the same directory as the virtual machine. This setting might degrade the VMotion performance.

WithVM - Store the swapfile in the same directory as the virtual machine.
falsefalse
WhatIfSwitchParameterIndicate that the cmdlet is run only to display the changes that would be made and actually no objects are modified.falsefalse

Return Type

VirtualMachine or Snapshot

Notes

Applying customization specs works only in 32-bit mode.

Examples

-------------- Example 1 --------------

$template = Get-VM VM | Set-VM -ToTemplate -Name VMTemplate

Converts the VM virtual machine to a template and stores the template in the $template variable.

-------------- Example 2 --------------

Get-VM -Location ResourcePool01 | Set-VM -MemoryGB 2 -NumCPU 2

Upgrades the memory and CPU count of the virtual machines in ResourcePool01.

-------------- Example 3 --------------

Set-VM -VM VM -Version v7

Upgrades the virtual hardware version of the VM machine.

-------------- Example 4 --------------

$snapshot = Get-Snapshot -VM $vm -Name "Initial state"

Set-VM -VM $vm -Snapshot $snapshot

Revert the VM virtual machine to the "Initial state" snapshot.

-------------- Example 5 --------------

$spec = Get-OSCustomizationSpec -Name FinanceDepartmentSpec;

Set-VM -VM $vm -OSCustomizationSpec $spec

Apply a customization specification on the specified virtual machines.

-------------- Example 6 --------------

Set-VM $vm -Name "Web Server" -GuestID winNetStandardGuest -Description "Company's web server"

Changes the name, description, and guest ID of the specified virtual machine.


Copyright © 1998 - 2012 VMware, Inc. All rights reserved.