< Back

Add-VMHost

Sun Jan 19, 2020 6:47 pm

NAME Add-VMHost



SYNOPSIS

This cmdlet adds a host to be managed by a vCenter Server system.





SYNTAX

Add-VMHost [-Name] <String> [-Location] <VIContainer> [-Credential <PSCredential>] [-Force] [-Password <String>]

[-Port <Int32>] [-RunAsync] [-Server <VIServer[]>] [-User <String>] [-Confirm] [-WhatIf] [<CommonParameters>]





DESCRIPTION

This cmdlet adds a host to be managed by a vCenter Server system. The host is added to the datacenter or folder

specified by the Location parameter. One of the User/Password and Credential parameters must be provided in order

to authenticate with the host. If both are specified, the Credential parameter is used and the User and Password

parameters are ignored.





PARAMETERS

-Credential <PSCredential>

Specifies a PSCredential object that contains credentials for authenticating with the virtual machine host.



Required? false

Position? named

Default value None

Accept pipeline input? False

Accept wildcard characters? false



-Force [<SwitchParameter>]

Indicates that the cmdlet runs even if the authenticity of the host SSL certificate cannot be verified.



Required? false

Position? named

Default value False

Accept pipeline input? False

Accept wildcard characters? false



-Location <VIContainer>

Specifies a datacenter or folder where you want to place the host.



Required? true

Position? 2

Default value None

Accept pipeline input? True (ByValue)

Accept wildcard characters? true



-Name <String>

Specifies the name of the host you want to add to a vCenter Server system.



Required? true

Position? 1

Default value None

Accept pipeline input? False

Accept wildcard characters? false



-Password <String>

Specifies the password you want to use for authenticating with the host.



Required? false

Position? named

Default value None

Accept pipeline input? False

Accept wildcard characters? false



-Port <Int32>

Specifies the port on the host you want to use for the connection.



Required? false

Position? named

Default value For ESX 2.x hosts this is the authd port (902 by default). For ESX 3.x and above

this is the https port (443 by default).

Accept pipeline input? False

Accept wildcard characters? false



-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 passed to this

parameter, the command runs on the default servers. For more information about default servers, see the

description of Connect-VIServer.



Required? false

Position? named

Default value None

Accept pipeline input? False

Accept wildcard characters? true



-User <String>

Specifies the user name you want to use for authenticating with the host.



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



<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

The newly added VMHost object







NOTES





Add-VMHost works only if there is a connection to vCenter Server.



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



$myServer = Connect-VIServer -Server 10.23.112.235

Add-VMHost -Server $myServer -Name MyVMHost1 -Location MyDatacenter1 -User MyUsername1 -Password MyPassword1



Adds a VM host to a specified vCenter Server system and provides a username and password for authentication.

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



$myCredentials = Get-VICredentialStoreItem -File "C:\\MyCredentials.xml"

$myServer = Connect-VIServer -Server 10.23.112.235

Add-VMHost -Server $myServer -Name MyVMHost1 -Location MyDatacenter1 -Credentials $myCredentials



Adds a VM host to a vCenter Server system and specifies a PSCredential object that contains authentication

credentials.

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



$myCredentials = Get-VICredentialStoreItem -File "C:\\MyCredentials.xml"

$myServer = Connect-VIServer -Server 10.23.112.235

Add-VMHost -Server $server -Name MyVMHost1 -Location MyDatacenter1 -Credentials $myCredentials -Port

MyVMHostPortNumber1 -Confirm:$false



Adds a VM host to a vCenter Server system without asking for confirmation and specifies a port on the host for

connecting.

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



$myCredentials = Get-VICredentialStoreItem -File "C:\\MyCredentials.xml"

$myServer = Connect-VIServer -Server 10.23.112.235

Add-VMHost -Server $myServer -Name MyVMHost1 -Location MyDataCenter1 -Credentials $myCredentials -Port

MyVMHostPortNumber1 -Force



Adds a VM host to a vCenter Server system even if the authenticity of the host SSL certificate cannot be verified.



RELATED LINKS

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

Get-VMHost

Move-VMHost

Remove-VMHost

Restart-VMHost

Set-VMHost

Start-VMHost

Stop-VMHost

Suspend-VMHost