Set-VM

This cmdlet modifies 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.

Syntax

-VM  <VirtualMachine[]>
[-AlternateGuestName  <String>]
[-CoresPerSocket  <Int32>]
[-DrsAutomationLevel  <DrsAutomationLevel>]
[-GuestId  <String>]
[-HAIsolationResponse  <HAIsolationResponse>]
[-HARestartPriority  <HARestartPriority>]
[-HardwareVersion  <String>]
[-MemoryGB  <Decimal>]
[-MemoryMB  <Int64>]
[-Name  <String>]
[-Notes  <String>]
[-NumCpu  <Int32>]
[-OSCustomizationSpec  <OSCustomizationSpec>]
[-RunAsync]
[-SEVEnabled  <Boolean>]
[-Server  <VIServer[]>]
[-VMSwapFilePolicy  <VMSwapfilePolicy>]
[-Version  <VMVersion>]
[CommonParameters]

Parameters

Required Parameter Name Type Position Features Description
required
VM
VirtualMachine[] named
  • pipeline
  • Specifies the virtual machine that you want to configure.
    optional
    AlternateGuestName
    String named Specifies the full name of the guest OS for the virtual machine if the value of the GuestID parameter is set to otherGuest or otherGuest64.
    optional
    CoresPerSocket
    Int32 named Specifies the number of virtual CPU cores per socket.
    optional
    DrsAutomationLevel
    DrsAutomationLevel named Specifies a Distributed Resource Scheduler (DRS) automation level. The valid values are FullyAutomated, Manual, 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 appears.
    optional
    GuestId
    String named Specifies 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.
    optional
    HAIsolationResponse
    HAIsolationResponse named Indicates whether the virtual machine should be powered off if a host determines that it's 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 appears.
    optional
    HARestartPriority
    HARestartPriority named Specifies the virtual machine High Availability (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 appears.
    optional
    HardwareVersion
    String named Specifies the version to which you want to upgrade the virtual machine. You cannot downgrade to an earlier version.
    optional
    MemoryGB
    Decimal named Specifies the memory size in gigabytes (GB).
    optional
    MemoryMB
    Int64 named This parameter is obsolete. Use MemoryGB instead. Specifies the memory size in megabytes (MB).
    optional
    Name
    String named Specifies a new name for the virtual machine.
    optional
    Notes
    String named Provides a description for the virtual machine. The alias of this parameter is Description.
    optional
    NumCpu
    Int32 named Specifies the number of virtual CPUs.
    optional
    OSCustomizationSpec
    OSCustomizationSpec named Specifies a customization specification you want to apply to the virtual machine. This works only in 32-bit mode.
    optional
    RunAsync
    SwitchParameter named Indicates 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 VMware PowerCLI console.
    optional
    SEVEnabled
    Boolean named Specifies whether SEV (Secure Encrypted Virtualization) is enabled or not. It allows the CPU to encrypt the memory and the state of the virtual machine. It is applicable for AMD CPUs only.
    optional
    Server
    VIServer[] named Specifies the vCenter Server systems on which you want to run the cmdlet. If no value is provided or $null value is passed to this parameter, the command runs on the default servers. For more information about default servers, see the description of the Connect-VIServer cmdlet.
    optional
    VMSwapFilePolicy
    VMSwapfilePolicy named Specifies the swapfile placement policy. The following values are valid:
    optional
    Version
    VMVersion named This parameter is deprecated. Use the HardwareVersion parameter instead. Specifies the version to which you want to upgrade the virtual machine. The valid values are v4, v7, v8, v9, v10, v11, v12, v13, and v14. You cannot downgrade to an earlier version.

    -DisableEncryption
    -VM  <VirtualMachine[]>
    [-RunAsync]
    [-Server  <VIServer[]>]
    [CommonParameters]

    Parameters

    Required Parameter Name Type Position Features Description
    required
    DisableEncryption
    SwitchParameter named Indicates that you want to decrypt the specified virtual machine.
    required
    VM
    VirtualMachine[] named
  • pipeline
  • Specifies the virtual machine that you want to configure.
    optional
    RunAsync
    SwitchParameter named Indicates 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 VMware PowerCLI console.
    optional
    Server
    VIServer[] named Specifies the vCenter Server systems on which you want to run the cmdlet. If no value is provided or $null value is passed to this parameter, the command runs on the default servers. For more information about default servers, see the description of the Connect-VIServer cmdlet.

    -VM  <VirtualMachine[]>
    [-KeyProvider  <KmsCluster>]
    [-RunAsync]
    [-Server  <VIServer[]>]
    [-SkipHardDisks]
    [-StoragePolicy  <StoragePolicy>]
    [CommonParameters]

    Parameters

    Required Parameter Name Type Position Features Description
    required
    VM
    VirtualMachine[] named
  • pipeline
  • Specifies the virtual machine that you want to configure.
    optional
    KeyProvider
    KmsCluster named Specifies the key provider that you want to use for the encryption key while encrypting the specified virtual machine. If StoragePolicy is not specified, the default encryption storage policy "VM Encryption Policy" is used.
    optional
    RunAsync
    SwitchParameter named Indicates 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 VMware PowerCLI console.
    optional
    Server
    VIServer[] named Specifies the vCenter Server systems on which you want to run the cmdlet. If no value is provided or $null value is passed to this parameter, the command runs on the default servers. For more information about default servers, see the description of the Connect-VIServer cmdlet.
    optional
    SkipHardDisks
    SwitchParameter named Indicates that the StoragePolicy or encryption (KeyProvider) is applied to vmhome only.
    optional
    StoragePolicy
    StoragePolicy named Specifies the StoragePolicy that you want to attach to the specified virtual machine. If the StoragePolicy is an encryption policy, the virtual machine is encrypted. Otherwise, the virtual machine is decrypted, if it's encrypted before the cmdlet, and attached with the new StoragePolicy.

    -VM  <VirtualMachine[]>
    [-PromoteDisks]
    [-RunAsync]
    [-Server  <VIServer[]>]
    [CommonParameters]

    Parameters

    Required Parameter Name Type Position Features Description
    required
    VM
    VirtualMachine[] named
  • pipeline
  • Specifies the virtual machine that you want to configure.
    optional
    PromoteDisks
    SwitchParameter named Promotes virtual machine disks. You can use this parameter to promote a linked clone virtual machine to a full clone.
    optional
    RunAsync
    SwitchParameter named Indicates 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 VMware PowerCLI console.
    optional
    Server
    VIServer[] named Specifies the vCenter Server systems on which you want to run the cmdlet. If no value is provided or $null value is passed to this parameter, the command runs on the default servers. For more information about default servers, see the description of the Connect-VIServer cmdlet.

    -VM  <VirtualMachine[]>
    [-DrsAutomationLevel  <DrsAutomationLevel>]
    [-HAIsolationResponse  <HAIsolationResponse>]
    [-HARestartPriority  <HARestartPriority>]
    [-Name  <String>]
    [-OSCustomizationSpec  <OSCustomizationSpec>]
    [-RunAsync]
    [-Server  <VIServer[]>]
    [-Snapshot  <Snapshot>]
    [-VMSwapFilePolicy  <VMSwapfilePolicy>]
    [CommonParameters]

    Parameters

    Required Parameter Name Type Position Features Description
    required
    VM
    VirtualMachine[] named
  • pipeline
  • Specifies the virtual machine that you want to configure.
    optional
    DrsAutomationLevel
    DrsAutomationLevel named Specifies a Distributed Resource Scheduler (DRS) automation level. The valid values are FullyAutomated, Manual, 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 appears.
    optional
    HAIsolationResponse
    HAIsolationResponse named Indicates whether the virtual machine should be powered off if a host determines that it's 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 appears.
    optional
    HARestartPriority
    HARestartPriority named Specifies the virtual machine High Availability (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 appears.
    optional
    Name
    String named Specifies a new name for the virtual machine.
    optional
    OSCustomizationSpec
    OSCustomizationSpec named Specifies a customization specification you want to apply to the virtual machine. This works only in 32-bit mode.
    optional
    RunAsync
    SwitchParameter named Indicates 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 VMware PowerCLI console.
    optional
    Server
    VIServer[] named Specifies the vCenter Server systems on which you want to run the cmdlet. If no value is provided or $null value is passed to this parameter, the command runs on the default servers. For more information about default servers, see the description of the Connect-VIServer cmdlet.
    optional
    Snapshot
    Snapshot named
  • pipeline
  • Specifies a snapshot whose state you want to apply to the virtual machine.
    optional
    VMSwapFilePolicy
    VMSwapfilePolicy named Specifies the swapfile placement policy. The following values are valid:

    -VM  <VirtualMachine[]>
    [-Name  <String>]
    [-RunAsync]
    [-Server  <VIServer[]>]
    [-ToTemplate]
    [CommonParameters]

    Parameters

    Required Parameter Name Type Position Features Description
    required
    VM
    VirtualMachine[] named
  • pipeline
  • Specifies the virtual machine that you want to configure.
    optional
    Name
    String named Specifies a new name for the virtual machine.
    optional
    RunAsync
    SwitchParameter named Indicates 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 VMware PowerCLI console.
    optional
    Server
    VIServer[] named Specifies the vCenter Server systems on which you want to run the cmdlet. If no value is provided or $null value is passed to this parameter, the command runs on the default servers. For more information about default servers, see the description of the Connect-VIServer cmdlet.
    optional
    ToTemplate
    SwitchParameter named Indicates that you want to convert the virtual machine to a template.

    Output

    VMware.VimAutomation.ViCore.Types.V1.Inventory.VirtualMachine

    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 -HardwareVersion vmx-07

    Upgrades the virtual hardware version of the VM virtual machine.

    Example 4

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

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

    Example 5

    $spec = Get-OSCustomizationSpec -Name FinanceDepartmentSpec;
    Set-VM -VM $vm -OSCustomizationSpec $spec

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

    Example 7

    $keyprovider = Get-KeyProvider | select -first 1
    Set-VM $vm -KeyProvider $keyprovider

    Encrypts the whole virtual machine stored in $vm including its VM Home and all its valid hard disks.

    Example 8

    $storagepolicy = Get-SpbmStoragePolicy | select -first 1
    Set-VM $vm -StoragePolicy $storagepolicy -SkipHardDisks

    Attaches the $storagepolicy to the VM Home of the $vm virtual machine: - If the $storagepolicy is an encryption policy, the VM Home of the $vm virtual machine is encrypted or re-encrypted with the new policy.

    Example 9

    Set-VM $vm -DisableEncryption

    Decrypts the whole virtual machine stored in $vm including its VM Home and all its valid hard disks.

    Example 10

    $vm = Get-VM -Name MyVM1
    Set-VM -VM $vm -SEVEnabled $true

    Enables SEV (Secure Encrypted Virtualization) for the MyVM1 virtual machine.

    Related Commands

    Feedback

    Was this page helpful?