Guest User

Untitled

a guest
Jan 24th, 2017
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. Function Add-ESXiToCluster {
  2. <#
  3. .SYNOPSIS
  4. Add ESXi host to Cluster
  5. .PARAMETER ESXiName
  6. Specifies the name (DNS or IP) of the ESXi host that you want to add to the cluster
  7. .PARAMETER ESXiUser
  8. Specifies the user name you want to use for authenticating with the ESXi.
  9. .PARAMETER ESXiPassword
  10. Specifies the password you want to use for authenticating with the ESXi.
  11. .PARAMETER ClusterName
  12. Specifies the name of the cluster that you want to add a ESXi
  13. .EXAMPLE
  14. Add-ESXiToCluster -ESXiName '10.20.30.40' -ESXiUser 'root' -ESXiPassword 'thePassword' -ClusterName 'theCluster'
  15. .NOTES
  16. Copyright VMware, Inc. 2013. All Rights Reserved.
  17. #>
  18.  
  19. Param(
  20. [Parameter(Mandatory=$true)]
  21. [ValidateNotNullOrEmpty()]
  22. [string]$ESXiName,
  23.  
  24. [Parameter(Mandatory=$true)]
  25. [ValidateNotNullOrEmpty()]
  26. [string]$ESXiUser,
  27.  
  28. [Parameter(Mandatory=$true)]
  29. [ValidateNotNullOrEmpty()]
  30. [string]$ESXiPassword,
  31.  
  32. [Parameter(Mandatory=$true)]
  33. [ValidateNotNullOrEmpty()]
  34. [string]$ClusterName
  35. )
  36.  
  37. "Retrieve Cluster: $ClusterName"
  38. $Cluster = Get-Cluster -Name $ClusterName
  39.  
  40. "Add ESXi $ESXiName to Cluster $Cluster.Name"
  41. Add-VMHost -Name $ESXiName -User $ESXiUser -Password $ESXiPassword -Location $Cluster.Name -Force
  42. }
Add Comment
Please, Sign In to add comment