VMware Cloud Community
mbabu1
Enthusiast
Enthusiast
Jump to solution

Authentication Services - Join domain for ESXi hosts

Hi LucD,

We have a few clusters where the hosts don't seem to have joined to a domain under authentication services. 

Is there a script available where a it will join the domain by providing the domain, username and password.

At the moment we have over 100 hosts with this issue.

See attached picture of the settings.

Thanks in advance.

Mo

 

 

Reply
0 Kudos
1 Solution

Accepted Solutions
wetnose88
Enthusiast
Enthusiast
Jump to solution

You can refer to this posted by Luc D

https://communities.vmware.com/t5/ESXi-Discussions/Script-to-get-if-ESXi-host-is-in-AD-or-not/td-p/4...

$report = foreach($vc in $global:DefaultVIServers){

    Get-VMHost -Server $vc | Get-VMHostAuthentication |

    Select @{N='vCenter';E={$vc.Name}},

        @{N='VMHost';E={$_.VMHost.Name}},

        @{N='AD Domain';E={$_.DOmain}}

}

 

$report | Export-Csv VC-ESXi-AD.csv -NoTypeInformation -UseCulture

View solution in original post

Reply
0 Kudos
5 Replies
mbabu1
Enthusiast
Enthusiast
Jump to solution

I have found the following from a search:

 

Get-VMHost | Get-VMHostAuthentication | Set-VMHostAuthentication -JoinDomain "prod.cyberintegration.net/cis/computers/esxi" -Username myusername -Password "mypassword" 

 How can I edit the script to run against a host.csv file which has a list of all the hosts...?

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

In a loop, something like this

# Assume the CSV has a column with the name HostName

Import-Csv -Path host.csv -PipelineVariable row |
Foreach-Object -Process {
  Get-VMHost -Name $row.HostName| Get-VMHostAuthentication | 
  Set-VMHostAuthentication -JoinDomain "prod.cyberintegration.net/cis/computers/esxi" -Username myusername -Password "mypassword"
}


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

mbabu1
Enthusiast
Enthusiast
Jump to solution

Thanks LucD,

I will give the script a try and report back with feedback.

Another question, is there a script I can run against a vCenter to check all esxi authentication services settings and see what hosts are missing the domains.

Thanks

Mo

Reply
0 Kudos
wetnose88
Enthusiast
Enthusiast
Jump to solution

You can refer to this posted by Luc D

https://communities.vmware.com/t5/ESXi-Discussions/Script-to-get-if-ESXi-host-is-in-AD-or-not/td-p/4...

$report = foreach($vc in $global:DefaultVIServers){

    Get-VMHost -Server $vc | Get-VMHostAuthentication |

    Select @{N='vCenter';E={$vc.Name}},

        @{N='VMHost';E={$_.VMHost.Name}},

        @{N='AD Domain';E={$_.DOmain}}

}

 

$report | Export-Csv VC-ESXi-AD.csv -NoTypeInformation -UseCulture

Reply
0 Kudos
mbabu1
Enthusiast
Enthusiast
Jump to solution

Thanks, that's worked perfectly.

Many thanks wetnose...legend

Mo

Reply
0 Kudos