VMware Cloud Community
RajuVCP
Hot Shot
Hot Shot
Jump to solution

Script to get if ESXi host is in AD or not

HI All,

Just curious to know if we have already created a Script which can give details if the Host is in AD or not.

I have many 10+ vCenter would like to have script which can scan all the host from 10+ vCenter and give the result in excel.

Thanks a ton in Advance.

Raju Gunnal VCP 4, VCP 5, VTSP 4, VTSP 5, ITIL V3 http://www.techtosolution.com
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Try something like this

$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


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

View solution in original post

0 Kudos
4 Replies
LucD
Leadership
Leadership
Jump to solution

Try something like this

$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


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

0 Kudos
RajuVCP
Hot Shot
Hot Shot
Jump to solution

Thanks LucD for help as always Smiley Happy

if am missing something here. I tried with the script line but didn't gave any output. Do I need to create any text file and show the hosts or vcenters.

Raju Gunnal VCP 4, VCP 5, VTSP 4, VTSP 5, ITIL V3 http://www.techtosolution.com
0 Kudos
LucD
Leadership
Leadership
Jump to solution

The script assumes that you are already connected to the all the vCenters you want to check.

It starts from $global:defaultviservers, that holds all the vCenter connections.

You can add a one or more Connect-VIServer lines at the beginning.


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

0 Kudos
RajuVCP
Hot Shot
Hot Shot
Jump to solution

That worked ..thanks LucD Smiley Happy

Raju Gunnal VCP 4, VCP 5, VTSP 4, VTSP 5, ITIL V3 http://www.techtosolution.com
0 Kudos