Set-VMHost

This cmdlet modifies the configuration of the host.

Syntax

[-VMHost]  <VMHost[]>
[-Evacuate]
[-LicenseKey  <String>]
[-Profile  <VMHostProfile>]
[-RunAsync]
[-Server  <VIServer[]>]
[-State  <VMHostState>]
[-TimeZone  <VMHostTimeZone>]
[-VMSwapfileDatastore  <Datastore>]
[-VMSwapfilePolicy  <VMSwapfilePolicy>]
[-VsanDataMigrationMode  <VsanDataMigrationMode>]
[CommonParameters]

Parameters

Required Parameter Name Type Position Features Description
required
VMHost
VMHost[] 1
  • wildcards
  • pipeline
  • Specifies the host you want to configure.
    optional
    Evacuate
    SwitchParameter named If the value is $true, vCenter Server system automatically reregisters the virtual machines that are compatible for reregistration. If they are not compatible, they remain on the host. If there are powered on virtual machines that cannot be reregistered, the operation waits until they are powered off manually. The Evacuate parameter is valid only when connected to a vCenter Server system and the State parameter is set to Maintenance. Also, the virtual machine host must be in a DRS-enabled cluster.
    optional
    LicenseKey
    String named Specifies the license key to be used by the host. You can set the host to evaluation mode by passing the 00000-00000-00000-00000-00000 evaluation key.
    optional
    Profile
    VMHostProfile named
  • wildcards
  • Specifies a host profile you want to associate with the host. If the value of this parameter is $null, the current profile association is removed.
    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
  • wildcards
  • 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
    State
    VMHostState named Specifies the state of the host. The valid values are Connected, Disconnected, and Maintenance. If there are powered on virtual machines on the host, you can set the host into a maintenance mode, only if it is a part of a DRS-enabled cluster. Before entering maintenance mode, if the host is fully automated, the cmdlet relocates all powered on virtual machines. If the host is not automated or partially automated, you must first generate a DRS recommendation and wait until all powered on virtual machines are relocated or powered off. In this case, you must specify the RunAsync parameter. Otherwise, an error appears.
    optional
    TimeZone
    VMHostTimeZone named
  • wildcards
  • Specifies the time zone for the host by using its name or by providing the corresponding time zone object. Time zone names support wildcards. If the wildcards match more than one time zone, an error appears. Time zone objects can only be applied to the hosts they originate from.
    optional
    VMSwapfileDatastore
    Datastore named
  • wildcards
  • Specifies a datastore that is visible to the host and can be used for storing swapfiles for the virtual machines that run on this host. Using a host-specific swap location might degrade the vMotion performance.
    optional
    VMSwapfilePolicy
    VMSwapfilePolicy named Specifies the swapfile placement policy. The following values are valid:
    optional
    VsanDataMigrationMode
    VsanDataMigrationMode named Specifies the special action to take regarding the vSAN data when moving in maintenance mode. The VsanDataMigrationMode parameter is valid only when connected to a vCenter Server system and when the State parameter is set to VMHostState.Maintenance.

    -DisableCryptoSafe
    -VMHost  <VMHost[]>
    [-Server  <VIServer[]>]
    [CommonParameters]

    Parameters

    Required Parameter Name Type Position Features Description
    required
    DisableCryptoSafe
    SwitchParameter named If the value is $true and the VMHost's previous CryptoState is Safe, the VMHost enters a PendingIncapable state. Otherwise, the VMHost remains in an Incapable state. For the PendingIncapable state, the vmhost is explicitly crypto disabled and pending reboot is to be applied. When vmhost is in this state, creating encrypted virtual machines is not allowed. You need a reboot to totally clean up and enter an Incapable state.
    required
    VMHost
    VMHost[] named
  • wildcards
  • pipeline
  • Specifies the host you want to configure.
    optional
    Server
    VIServer[] named
  • wildcards
  • 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.

    -KeyProvider  <KmsCluster>
    -VMHost  <VMHost[]>
    [-Server  <VIServer[]>]
    [CommonParameters]

    Parameters

    Required Parameter Name Type Position Features Description
    required
    KeyProvider
    KmsCluster named Specifies the key provider you want to use to make the VMHost cryptographically "Safe" or rekey the VMHost's host key.
    required
    VMHost
    VMHost[] named
  • wildcards
  • pipeline
  • Specifies the host you want to configure.
    optional
    Server
    VIServer[] named
  • wildcards
  • 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.

    Output

    VMware.VimAutomation.ViCore.Types.V1.Inventory.VMHost

    Examples


    Example 1

    Set-VMHost -VMHost Host -State "Disconnected"

    Resets the state of the Host virtual host to Disconnected.

    Example 2

    $cluster = Get-Cluster -VMHost Host
    $task = Set-VMHost -VMHost Host -State "Maintenance" -RunAsync
    Get-DrsRecommendation -Cluster $cluster | where {$_.Reason -eq "Host is entering maintenance mode"} | Apply-DrsRecommendation
    $vmhost = Wait-Task $task

    Activates a maintenance mode for a not automated host that is part of a DRS-enabled cluster and has powered on virtual machines on it.

    Example 3

    $keyprovider = Get-KeyProvider | select -First 1
    Set-VMHost -VMHost Host -KeyProvider $keyprovider

    Resets the cryptokey of the VMHost named 'Host'.

    Related Commands

    Feedback

    Was this page helpful?