Set-VMHost
This cmdlet modifies the configuration of the host.The State parameter is set to Connected. - If the host is currently connected and is not in a maintenance mode, it does nothing.- If the host is in a maintenance mode, it exits the maintenance mode.- If the host is not connected or is not responding, it tries to reconnect.The State parameter is set to Disconnected. - If the host is currently connected, it attempts to disconnect.- If the host is not connected or not responding, it does nothing.The State parameter is set to Maintenance. - If the host is currently connected and not in a maintenance mode, it enters a maintenance mode.- If the host is currently connected and in a maintenance mode, it does nothing.- If the host is not connected or not responding, it attempts to reconnect and enter maintenance mode.The KeyProvider parameter is provided: - If the host is not in a cryptographically "Safe" state, the cmdlet makes the host cryptographically "Safe".- If the host is already in a cryptographically "Safe" state, the cmdlet resets the host key in the host.
Syntax
Parameters
Required | Parameter Name | Type | Position | Features | Description |
---|---|---|---|---|---|
required
|
VMHost | VMHost[] | 1 |
|
Specifies the host you want to configure. |
optional | BaseImage | BaseImage | named |
|
Specifies the ESXi base image that the host should comply with. |
optional | Component | Component[] | named |
|
Specifies the ESXi component(s) that the host should comply with. |
optional | DepotOverride | String[] | named |
|
Specifies a depot address from where the host can fetch metadata and resources for the vSphere Lifecycle Manager operations. |
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 | FirmwareAddon | Package | named |
|
Specifies a package from a hardware support manager that the host should comply with. |
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 |
|
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 | ProgressAction | ActionPreference | named |
|
|
optional | Reason | String | named |
|
Specifies a short message containing the reason for putting the host in maintenance mode. The message cannot be null or empty string. This parameter can only be used when passing "Maintenance" value to the "State" parameter. |
optional | RemovedComponent | String[] | named |
|
Specifies a list of components that you want to remove from the base image. Calling the commandlet with a new value for this parameter overrides any previously configured value. It does not add new components to the list of removed ones. To reset the list of removed components provide an empty array to this parameter. |
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 | 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 |
|
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 |
|
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: InHostDataStore - stores 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 - stores the swapfile in the same directory as the virtual machine. |
optional | VendorAddOn | AddOn | named |
|
Specifies the ESXi vendor add-on that the host should comply with. |
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. |
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 deactivated 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 |
|
Specifies the host you want to configure. |
optional | BaseImage | BaseImage | named |
|
Specifies the ESXi base image that the host should comply with. |
optional | Component | Component[] | named |
|
Specifies the ESXi component(s) that the host should comply with. |
optional | DepotOverride | String[] | named |
|
Specifies a depot address from where the host can fetch metadata and resources for the vSphere Lifecycle Manager operations. |
optional | FirmwareAddon | Package | named |
|
Specifies a package from a hardware support manager that the host should comply with. |
optional | ProgressAction | ActionPreference | named |
|
|
optional | RemovedComponent | String[] | named |
|
Specifies a list of components that you want to remove from the base image. Calling the commandlet with a new value for this parameter overrides any previously configured value. It does not add new components to the list of removed ones. To reset the list of removed components provide an empty array to this parameter. |
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 | VendorAddOn | AddOn | named |
|
Specifies the ESXi vendor add-on that the host should comply with. |
Parameters
Required | Parameter Name | Type | Position | Features | Description |
---|---|---|---|---|---|
required
|
KeyProvider | KeyProvider | 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 |
|
Specifies the host you want to configure. |
optional | BaseImage | BaseImage | named |
|
Specifies the ESXi base image that the host should comply with. |
optional | Component | Component[] | named |
|
Specifies the ESXi component(s) that the host should comply with. |
optional | DepotOverride | String[] | named |
|
Specifies a depot address from where the host can fetch metadata and resources for the vSphere Lifecycle Manager operations. |
optional | FirmwareAddon | Package | named |
|
Specifies a package from a hardware support manager that the host should comply with. |
optional | ProgressAction | ActionPreference | named |
|
|
optional | RemovedComponent | String[] | named |
|
Specifies a list of components that you want to remove from the base image. Calling the commandlet with a new value for this parameter overrides any previously configured value. It does not add new components to the list of removed ones. To reset the list of removed components provide an empty array to this parameter. |
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 | VendorAddOn | AddOn | named |
|
Specifies the ESXi vendor add-on that the host should comply with. |
Output
VMware.VimAutomation.ViCore.Types.V1.Inventory.VMHostExamples
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'.
Example 4
Set-VMHost -VMHost Host -BaseImage $myBaseImage -RemovedComponent "VMware Host Client"
Customizes the base image by removing a component. With vSphere 8.0 Update 3, you can remove only the VMware Host Client and ESXi VM Tools components from the base image.
Related Commands
VMHost
This cmdlet adds a host to be managed by a vCenter Server system.
This cmdlet retrieves the hosts on a vCenter Server system.
This cmdlet moves hosts to another location.
This cmdlet removes the specified hosts from the inventory.
This cmdlet restarts the specified hosts.
This cmdlet modifies the configuration of the host.
This cmdlet starts the specified hosts.
This cmdlet powers off the specified hosts.
This cmdlet suspends hosts.
VMHostAccount
This cmdlet retrieves the host accounts available on a vCenter Server system.
This cmdlet creates a new host user or group account.
This cmdlet removes the specified host accounts.
This cmdlet configures a host account.
VMHostAdvancedConfiguration
This cmdlet retrieves the advanced configuration of the hosts.
This cmdlet modifies the advanced configuration settings of a host.
VMHostAttributes
Gets the identifying attributes of a host.
VMHostAuthentication
This cmdlet retrieves authentication information for the specified hosts.
This cmdlet modifies the host authentication information.
VMHostAvailableTimeZone
This cmdlet retrieves the time zones available on the specified host.
VMHostDiagnosticPartition
This cmdlet retrieves a list of the diagnostic partitions on the specified hosts.
This cmdlet activates or deactivates the diagnostic partitions of hosts.
VMHostDisk
This cmdlet retrieves information about the specified SCSI LUN disk.
VMHostDiskPartition
This cmdlet formats a new VMFS (Virtual Machine File System) on each of the specified host disk partitions.
This cmdlet retrieves the partitions of a host disk (LUN).
VMHostFirewallDefaultPolicy
This cmdlet retrieves the firewall default policy of the specified hosts.
This cmdlet sets the default policy for the specified host firewall.
VMHostFirewallException
This cmdlet retrieves the exceptions from the firewall policy on the specified hosts.
This cmdlet activates or deactivates host firewall exceptions.
VMHostFirmware
This cmdlet retrieves hosts firmware information.
This cmdlet configures hosts firmware settings.
VMHostHardware
This cmdlet retrieves ESXi host hardware and firmware information.
VMHostHba
This cmdlet retrieves information about the available HBAs (Host Bus Adapter).
This cmdlet configures the CHAP properties of the specified iSCSI HBAs.
VMHostImageDb
This cmdlet exports the specified host's base image database to a file that is in a .tgz format.
VMHostImageProfile
Gets the image profile associated with the specified ESXi host.
VMHostMatchingRules
Retrieves the list of rules in the rule set that match a specified host.
VMHostModule
This cmdlet retrieves the option strings of the specified host modules.
This cmdlet overrides the host module options with the given ones.
VMHostNetwork
THis cmdlet retrieves the host networks on a vCenter Server system.
This cmdlet updates the specified virtual network.
VMHostNetworkAdapter
This cmdlet retrieves the host network adapters on a vCenter Server system.
This cmdlet creates a new HostVirtualNIC (Service Console or VMKernel) on the specified host.
This cmdlet removes the specified host network adapters.
This cmdlet configures the specified host network adapter.
VMHostNetworkStack
This cmdlet retrieves the host network stacks on a vCenter Server system.
This cmdlet modifies the specified host network stack.
VMHostNtpServer
This cmdlet adds the specified NTP servers to the NTP server list of the specified hosts.
This cmdlet retrieves the NTP servers on the specified hosts.
This cmdlet removes the specified NTP servers from the NTP server list of the specified hosts.
VMHostPatch
This cmdlet retrieves information about the host patches installed on the specified hosts. This cmdlet is deprecated and will not return any results for ESX hosts version 5.0 and later. Use (Get-ESXCli).software.vib.list() as an alternative.
This cmdlet updates the specified hosts.
VMHostPciDevice
This cmdlet retrieves the PCI devices on the specified hosts.
VMHostProfile
This cmdlet exports the specified host profile to a file.
This cmdlet retrieves the available host profiles.
This cmdlet imports a host profile from a file. The file path must be accessible from the VMware PowerCLI client side.
This cmdlet applies a host profile to the specified host or cluster.
This cmdlet creates a new host profile based on a reference host.
This cmdlet removes the specified host profiles.
This cmdlet modifies the specified host profile.
VMHostProfileCompliance
This cmdlet tests hosts for profile compliance.
VMHostProfileImageCacheConfiguration
Retrieves an image cache configuration for the given host profile.
This cmdlet modifies image cache configuration for given host profile.
VMHostProfileRequiredInput
This cmdlet performs a check whether the available information is sufficient to apply a host profile.
VMHostProfileStorageDeviceConfiguration
Retrieves the storage device configuration for the given host profile.
This cmdlet modifies the storage device configuration for the given host profile.
VMHostProfileUserConfiguration
This cmdlet retrieves the user password configuration for the given host profile.
This cmdlet modifies the user password configuration for the specified account within a host profile.
VMHostProfileVmPortGroupConfiguration
Retrieves the virtual machine port group configuration for the given host profile.
This cmdlet creates a new virtual machine port group configuration.
Removes the given virtual machine port group configuration from the host profile.
This cmdlet modifies the virtual machine port group configuration for the given host profile.
VMHostRoute
This cmdlet retrieves the routes from the routing table of the specified hosts.
This cmdlet creates a new route in the routing table of a host.
This cmdlet removes host routes.
This cmdlet modifies a route in the host routing table.
VMHostService
This cmdlet retrieves information about a host service.
This cmdlet restarts the specified host services.
This cmdlet modifies a host service.
This cmdlet starts the specified host services.
This cmdlet stops the specified host services.
VMHostSnmp
This cmdlet retrieves hosts SNMP configuration.
This cmdlet modifies the host SNMP configuration.
This cmdlet tests the host SNMP.
VMHostStartPolicy
This cmdlet retrieves the start policy of hosts.
This cmdlet modifies the host default start policy.
VMHostStorage
This cmdlet retrieves the host storages on a vCenter Server system.
This cmdlet configures a host storage.
VMHostSysLogServer
This cmdlet displays the remote syslog servers of the specified hosts.
This cmdlet configures the remote syslog server of the specified hosts.
VMHostTPM
This cmdlet retrieves the TPM 2.0 devices from the specified host.