powershellscripts.com

Tutorials  PowerShell Cmdlet Help for Set-VMHost



NAME
Set-VMHost

SYNOPSIS
Changes the configuration of the host.

SYNTAX
Set-VMHost [-VMHost] [[-State] ] [-VMSwapfilePolicy ] [-VMSwapfileDatasto
re ] [-Profile ] [-Evacuate] [-TimeZone ] [-Server ] [-RunAsy
nc] [-WhatIf] [-Confirm] []


DESCRIPTION
Changes 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.


PARAMETERS
-VMHost
Specify the host you want to configure.

Required? true
Position? 2
Default value
Accept pipeline input? true (ByValue)
Accept wildcard characters? true

-State
Specify the state of the host. The valid values are Connected, Disconnected, and Maintenance. If there are powe
red on virtual machines on the host, you can set the host into a maintenance mode, only if it is part of a DRS
-enabled cluster. Before entering the maintenance mode, if the host is fully automated, the cmdlet first reloca
tes all powered on virtual machines. If the host is not automated or partially automated, you must first genera
te a DRS recommendation and wait until all powered on virtual machines are relocated or powered off. In this ca
se, you must specify the RunAsync parameter, otherwise an error is thrown.

Required? false
Position? 1
Default value
Accept pipeline input? false
Accept wildcard characters? false

-VMSwapfilePolicy
Specify the swapfile placement policy. The following values are valid:

InHostDataStore - Store the swapfile in the datastore specified by the VMSwapfileDatastoreID property of the vi
rtual 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 th
e VMotion performance.

WithVM - Store the swapfile in the same directory as the virtual machine.

This parameter is supported only on vCenter Server 2.5 and ESX 3.5 servers, or later versions.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

-VMSwapfileDatastore
Specify 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. This paramete
r is supported only on vCenter Server 2.5 and ESX 3.5 servers, or later versions.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? true

-Profile
Specify a host profile you want to associate with the host. If the value of this parameter is $null, the curren
t profile association is removed.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? true

-Evacuate
If the value is $true, vCenter automatically reregisters the virtual machines that are compatible for reregistr
ation. If they are not compatible, they remain on the host. If there are powered on virtual machines that canno
t be reregistered the operation waits until they are powered off manually. The -Evacuate parameter is valid onl
y 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
Accept pipeline input? false
Accept wildcard characters? false

-TimeZone
Specify the time zone for the host by using its name or by providing the corresponding time zone object. Time z
one names support wildcards. If the wildcards match more than one time zones, an error is reported. Time zone o
bjects can only be applied to the hosts they originate from.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? true

-Server
Specify the vSphere servers on which you want to run the cmdlet. If no value is given to this parameter, the co
mmand runs on the default servers. For more information about default servers, see the description of Connect-V
IServer.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? true

-RunAsync
Indicate that the command returns immediately without waiting for the task to complete. In this mode, the outpu
t of the cmdlet is a Task object. For more information about the -RunAsync parameter run " help About_RunAsync"
in the vSphere PowerCLI console.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

-WhatIf
Indicate that the cmdlet is run only to display the changes that would be made and actually no objects are modi
fied.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

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


This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

INPUTS



OUTPUTS
VMHost


NOTES


The -TimeZone parameter is supported only on ESX 3.5 /VirtualCenter 2.5, ESX 4.0/vCenter Server 4.0, and higher
.
The -Evacuate parameter is valid only when connected to a vCenter Server host and the host is a part of a DRS-e
nabled cluster.

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

C:\PS>Set-VMHost -VMHost Host -State "Disconnected"


Resets the state of the Host virtual host to disconnected.





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

C:\PS>$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-DrsReco
mmendation

$host = Wait-Task $task


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






RELATED LINKS
Online version: http://www.vmware.com/support/developer/PowerCLI/PowerCLI501/html/Set-VMHost.html
Add-VMHost
Get-VMHost
Move-VMHost
Remove-VMHost
Restart-VMHost
Start-VMHost
Stop-VMHost
Suspend-VMHost