5

I would like to retrieve a list of computers which are part of the Windows domain my Windows 7 workstation is a member of.

I would like to achieve this with little to no extra installations, especially not the 230MB Remote Server Administration Tools package Microsoft offers.

The options I have seen thus far include the DSQuery tool (part of the RSAT package) and the ActiveDirectory module for PowerShell (also part of the RSAT package).

  • Could there maybe be an option to use the PowerShell module alone (scripts only) or is every bit of the 230MB toolset really required?
  • Is there another option I missed?

Regarding permissions of the user which will perform the query, I would like to be able to use an unprivileged domain user, but an Administrator is also an option if the there are no unprivileged alternatives.

I will also mention that the net view command displays a few computers in the same subnet or otherwise "near" the workstation, but obviously not all computers in the domain. On the other hand, the command net view /domain:<domain_name> displays no results, and returns error 6118 (which is strange because then I would expect net view to also display no results).

Charles
  • 53
  • 4

1 Answers1

4

You can always use the ADSI interfaces via PowerShell/.NET and the System.DirectoryServices namespace.

Here's a quick example using DirectorySearcher assuming you're running PowerShell as a standard domain user.

$searcher = New-Object DirectoryServices.DirectorySearcher
$searcher.Filter = '(objectclass=computer)'
$searcher.SearchRoot = 'LDAP://DC=example,DC=com'
$searcher.FindAll()

It's not as nice as working with the ActiveDirectory module in my opinion. But it's definitely doable and in some cases can be faster than the ActiveDirectory module.

You may also be able to pull just the ActiveDirectory module files out of another installation and add them to your personal profile rather than needing to install the entire RSAT package. If I recall correctly, it's one folder and about 5 MB worth of files.

Ryan Bolger
  • 16,755
  • 4
  • 42
  • 64