vSphere PowerCLI Reference



Applies a host profile to the specified host or cluster.


Apply-VMHostProfile [-Entity] <InventoryItem[]> [-Profile <VMHostProfile>] [-Variable <Hashtable>] [-AssociateOnly] [-ApplyOnly] [-RunAsync] [-Server <VIServer[]>] [-WhatIf] [-Confirm] [<CommonParameters>]

Related Commands

Online version

Detailed Description

Applies a host profile to the specified host or cluster. The host or cluster must be in a maintenance mode. If no value is provided to the -Profile parameter, the profile currently associated with the host or cluster is applied.


NameTypeDescriptionRequired?Pipeline InputDefault Value
EntityInventoryItem[]Specify hosts or clusters to which you want to apply the virtual machine host profile.truetrue (ByValue)
ApplyOnlySwitchParameterIndicate whether to apply the host profile to the specified virtual machine host without associating it.falsefalse
AssociateOnlySwitchParameterIndicate whether to associate the host profile to the specified host or cluster without applying it.falsefalse
ConfirmSwitchParameterIf 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.falsefalse$true
ProfileVMHostProfileSpecify the host profile you want to apply.falsetrue (ByValue)
RunAsyncSwitchParameterIndicate 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 vSphere PowerCLI console.falsefalse
ServerVIServer[]Specify the vSphere servers 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 Connect-VIServer.falsefalse
VariableHashtableSpecify a hash table object that provides values for the host profile required variables.falsetrue (ByValue)
WhatIfSwitchParameterIndicate that the cmdlet is run only to display the changes that would be made and actually no objects are modified.falsefalse

Return Type

VMHost or Cluster or System.Collections.Hashtable


If there are missing values for the required variables, a hash table with t he names of the required variables and the current or default values is ret urned. Otherwise, all directly affected host and cluster objects are return ed. If the cmdlet is run for a cluster with the -AssociateOnly parameter se t, only the cluster object is returned, but not its hosts.


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

Apply-VMHostProfile -AssociateOnly -Entity $cluster -Profile $profile

Associates the specified profile to all hosts in the specified cluster.

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

Apply-VMHostProfile -Entity $host -Profile $profile

Associates and applies the specified profile to the specified host.

-------------- Example 3 --------------

Get-VMHost | Apply-VMHostProfile -ApplyOnly -Profile $profile

Applies the specified profile to all specified hosts.

-------------- Example 4 --------------

Get-VMHost | Apply-VMHostProfile -AssociateOnly -profile $profile

Asscociates the specified profile to all specified hosts.

-------------- Example 5 --------------

Apply-VMHostProfile $host

Applies the associated host's profile to the host.

-------------- Example 6 --------------

$requireInput = Apply-VMHostProfile $host -Profile $profile;  $requireInput['network.hostPortGroup["key-vim-profile-host-HostPortgroupProfile-VMkernel"].ipConfig.IpAddressPolicy.address'] = '';  $requireInput['network.hostPortGroup["key-vim-profile-host-HostPortgroupProfile-VMkernel"].ipConfig.IpAddressPolicy.subnetmask'] = '';  Apply-VMHostProfile $host -Profile $profile -Variable $requireInput;

Applies a profile to host but first assigns values to all required values.

Copyright © 1998 - 2011 VMware, Inc. All rights reserved.