0

I want to print a list of all the hosts connected to the domain.

I'm looking for a command which does more or less what that one in Powershell does, but for Linux:

Get-ADComputer -Filter * | ForEach-Object {$_.Name}

So, what I want to do is getting a list with all the hosts on a domain and then compare it with all the hosts which are already monitored with Nagios.

2
  • ldapsearch -LLL -H ldap://ad.ourdomain.local -x -D 'OURDOMAIN\user' -w 'thepassword' -b 'dc=ourdomain,dc=local' 'objectClass=computer' name
    – Dobi
    Oct 6, 2014 at 12:11
  • Dobi is right : use the LDAP interface of Active Directory and make a request on computer names. Oct 23, 2014 at 8:37

2 Answers 2

1

Presuming you have joined the domain using Samba, you should have the nmblookup. In that case, it would be something like

nmblookup '*'

The two problems are firstly, it will use NetBIOS to do the lookup, and all the fun that NetBIOS brings with it; secondly, this will show more than you are looking for; it also shows shares and other information.

You may be better served by using a Linux port of WSMAN (like http://openwsman.github.io/) to reach out to one of the Windows servers with WinRM (instructions are at here) to execute your Power Shell command.

1

You may want to consider that AD keeps an account for every computer, and exposes this information via LDAP. The sample query below is from memory (quickly jogged by Google), since I am not in my AD environment right now.

ldapsearch -h dc0.example.com -p 389 -b "dc=example,dc=com" -s sub "(objectCategory=computer)" canonicalName

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .