< Back

Set-VMHost

Sun Jan 19, 2020 7:10 pm

NAME Set-VMHost



SYNOPSIS

This cmdlet modifies the configuration of the host.





SYNTAX

Set-VMHost [[-State] <VMHostState>] [-VMHost] <VMHost[]> [-Evacuate] [-LicenseKey <String>] [-Profile

<VMHostProfile>] [-RunAsync] [-Server <VIServer[]>] [-TimeZone <VMHostTimeZone>] [-VMSwapfileDatastore

<Datastore>] [-VMSwapfilePolicy <VMSwapfilePolicy>] [-VsanDataMigrationMode <VsanDataMigrationMode>] [-Confirm]

[-WhatIf] [<CommonParameters>]



Set-VMHost [-VMHost] <VMHost[]> [-Server <VIServer[]>] [-Confirm] [-WhatIf] -KmsCluster <KmsCluster>

[<CommonParameters>]





DESCRIPTION

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 KmsCluster parameter is provided: - If the host is not in CryptoSafe state, the cmdlet makes the host

CryptoSafe.



- If the host is already in CryptoSafe state, the cmdlet resets the CryptoKey in the host.







PARAMETERS

-Evacuate [<SwitchParameter>]

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.



Required? false

Position? named

Default value False

Accept pipeline input? False

Accept wildcard characters? false



-LicenseKey <String>

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.



Required? false

Position? named

Default value None

Accept pipeline input? False

Accept wildcard characters? false



-Profile <VMHostProfile>

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.



Required? false

Position? named

Default value None

Accept pipeline input? False

Accept wildcard characters? true



-RunAsync [<SwitchParameter>]

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.



Required? false

Position? named

Default value False

Accept pipeline input? False

Accept wildcard characters? false



-Server <VIServer[]>

Specifies the vCenter Server systems 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 the Connect-VIServer cmdlet.



Required? false

Position? named

Default value None

Accept pipeline input? False

Accept wildcard characters? true



-State <VMHostState>

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



Required? false

Position? 1

Default value None

Accept pipeline input? False

Accept wildcard characters? false



-TimeZone <VMHostTimeZone>

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 zones, an error is reported. Time

zone objects can only be applied to the hosts they originate from.



Required? false

Position? named

Default value None

Accept pipeline input? False

Accept wildcard characters? true



-VMHost <VMHost[]>

Specifies the host you want to configure.



Required? true

Position? 2

Default value None

Accept pipeline input? True (ByValue)

Accept wildcard characters? true



-VMSwapfileDatastore <Datastore>

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.



Required? false

Position? named

Default value None

Accept pipeline input? False

Accept wildcard characters? true



-VMSwapfilePolicy <VMSwapfilePolicy>

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.



Required? false

Position? named

Default value None

Accept pipeline input? False

Accept wildcard characters? false



-VsanDataMigrationMode <VsanDataMigrationMode>

Specifies the special action to take regarding Virtual SAN data when moving in maintenance mode. The

VsanDataMigrationMode parameter is valid only when connected to a vCenter Server system and when State

parameter is set to VMHostState.Maintenance.



Required? false

Position? named

Default value None

Accept pipeline input? False

Accept wildcard characters? false



-Confirm [<SwitchParameter>]

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



Required? false

Position? named

Default value $true

Accept pipeline input? False

Accept wildcard characters? false



-WhatIf [<SwitchParameter>]

Indicates that the cmdlet is run only to display the changes that would be made and actually no objects are

modified.



Required? false

Position? named

Default value False

Accept pipeline input? False

Accept wildcard characters? false



-KmsCluster <KmsCluster>

Specifies the KmsCluster which will be used to generate a key to set the host.



Required? true

Position? named

Default value None

Accept pipeline input? False

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).



INPUTS



OUTPUTS

Zero or more modified VMHost objects







NOTES





The TimeZone parameter is supported only on ESX 4.1/vCenter Server 4.1, and later. The Evacuate parameter is

valid only when connected to a vCenter Server system and the host is a part of a DRS-enabled cluster. The

VsanDataMigrationMode parameter is valid only when connected to a vCenter Server system and when State

parameter is set to VMHostState.Maintenance.



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



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



$kmsCluster = Get-KmsCluster | select -First 1

Set-VMHost -VMHost Host -KmsCluster $kmsCluster



Resets the cryptokey of the VMHost named 'Host'.



RELATED LINKS

Online Version: https://code.vmware.com/doc/preview?id= ... MHost.html

Add-VMHost

Get-VMHost

Move-VMHost

Remove-VMHost

Restart-VMHost

Start-VMHost

Stop-VMHost

Suspend-VMHost

Unknown