VMware Cloud Community
KarlMitschke
Contributor
Contributor

Create a list of servers?

Is there any way to create a list of servers using VMware vSphereTM PowerCLI?

I'm spoiled by the Exchange Management Shell where I can do Get-ExchangeServer or Get-MailboxServer

I'd love to see a Get-VIServer cmdlet.

I am building a script that will inventory all my physical and virtual servers. These servers can be running Windows, Unix, AIX, Linux, Novell, etcetera.

i cannot rely on the team that builds the VI server to give me the name of each server (or put it in a file for my scrit to read)

This process has to be self contained.

Additionally, I am only doing this for one agency in the orginization (Think of it as 1 company, with 30 other companies sharing our infrastructure - i can only touch our servers)

Anyhow, i need a way to discover VI servers

Thanks

Krl

0 Kudos
3 Replies
LucD
Leadership
Leadership

The following script will send a WMI query to all computers in a specific OU.

The WMI query will check if the server has the VMware VirtualCenter Server service running.

The script will display all servers that were discovered.

This will of course only work for Windows servers in an Active Directory environment.

$domain = "LDAP://<domain-DN>"
$searcher = New-Object System.DirectoryServices.DirectorySearcher $domain
$searcher.SearchRoot = "LDAP://<Server-OU-DN>"
$searcher.Filter = '(&(objectClass=Computer))'
$searcher.PropertiesToLoad.Add("dNSHostName")

$report = @()
$searcher.FindAll() | %{
  $VC = get-wmiobject win32_service -filter "name='vpxd'" -ComputerName ($_.Properties) -erroraction SilentlyContinue
  if($VC -ne $null){
     $report += ($_.Properties)
  }
}

Write-Host "Discovered Virtual Center servers"
$report


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

0 Kudos
KarlMitschke
Contributor
Contributor

I found out I can connect to my VIC, and it will report on all 438 servers on our 28 hosts Smiley Happy

0 Kudos
LucD
Leadership
Leadership

Ok, it seems I misunderstood your question.

I assumed you were trying to find out on which server the Virtual Center was running.


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

0 Kudos