VMware Cloud Community
jravnsba
Contributor
Contributor
Jump to solution

Howto join ESXi 5 to AD domain using PowerCLI

I unable to add ESXi 5 hosts to AD domain using PowerCli 5.

I have tried using LucD note, but it doesn't work probably because it only supports ESXi 4.1

http://www.lucd.info/2010/07/25/script-vsphere-4-1-ad-authentication/

Does anyone know how to add ESXi 5 host to domain using PowerCli, any new cmdlet like JoinDomain etc. ?

Joern

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

I have to update that post.

Try replacing line 123

$hostADAuth= [VMware.Vim.VIConvert]::ToVim41($result)

with

$hostADAuth= [VMware.Vim.VIConvert]::ToVim50($result)


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

0 Kudos
12 Replies
LucD
Leadership
Leadership
Jump to solution

I have to update that post.

Try replacing line 123

$hostADAuth= [VMware.Vim.VIConvert]::ToVim41($result)

with

$hostADAuth= [VMware.Vim.VIConvert]::ToVim50($result)


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
jravnsba
Contributor
Contributor
Jump to solution

You an Expert.

It works !

0 Kudos
fredlock
Contributor
Contributor
Jump to solution

The link to  the script is not working....

0 Kudos
LucD
Leadership
Leadership
Jump to solution

Seems to work from here.

The site might have been unavailable, still no access ?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
fredlock
Contributor
Contributor
Jump to solution

yes Luc

Link is working fine now

thank you

0 Kudos
AtanasAtanasov
VMware Employee
VMware Employee
Jump to solution

Hi Joern,

You can also check out PowerCLI cmdlets - Get-VMHostAuthentication and Set-VMHostAuthentication.

0 Kudos
LucD
Leadership
Leadership
Jump to solution

Correct, my AD join functions were written before those cmdlets existed.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
jravnsba
Contributor
Contributor
Jump to solution

When I try to use GetVMHostAuthenticaiton I get a failure:


The term 'GetVMHostAuthentication' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

If it worked it could be cool, but if I don't want to store user and password in the script and just want to be prompted, how do I do this ?

Another question related to scripts:
Is is possible to have a main script that calls all sub scripts ?

Main.ps1

$ESXHOST = Read-Host "Enter ESX Host Name or IP"
Connect-VIServer $ESXHOST
 

   @ConfigureNTP

   @ConfigureVMOTION

   @ConfigureTCPNFS

   @AddNFSVolumes

   ......

   ......

   ......

   ......

Write-Host "$($ESXHOST fully configured !!!" -ForegroundColor Yellow

0 Kudos
LucD
Leadership
Leadership
Jump to solution

Which PowerCLI version are you using ?

Do a

Get-PowerCLIVersion

Sure, just make sure the scopes are set up correctly.

It's preferable to pass parameters to the functions instead of accessing variables in the 'main' part from within the functions.

And I don't think your function names can start with @


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
jravnsba
Contributor
Contributor
Jump to solution

PowerCLI Version
----------------
   VMware vSphere PowerCLI 5.0 build 435427
---------------
Snapin Versions
---------------
   VMWare AutoDeploy PowerCLI 5.0 build 575
   VMWare ImageBuilder PowerCLI 5.0 build 575
   VMware License PowerCLI 5.0 build 395016
   VMWare vSphere PowerCLI 5.0 build 435427

I'm not sure what you mean about 'scope' set up correctly ?

/Joern

0 Kudos
LucD
Leadership
Leadership
Jump to solution

The Get-VMHostAuthentication cmdlet was added in PowerCLI 5.0, so you should be able to call it.

Strange.

See about_scopes,

In short each function has it's own scope (stack) of variables. When your script addresses a variable, the PS engine will look in the function stack. If the variable is not there, the engine will look in the parent stack, and so on.

It's not considered good programming practice to refer, in functions, to variables that are defined on parent's stack.

It's better, and less error prone, to pass these as parameters to the function, or let the function return an object and store that in the parent's variable.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

jravnsba
Contributor
Contributor
Jump to solution

Hi Luc

It was because I have pasted a script and there was no hyphen in the command GetVMHostAuthenticaiton

It should of cause have been Get-VMHostAuthenticaiton

Thank you for the help anyway

0 Kudos