Windows Vista Forums

How to limit AD search to just servers.
  1. #1


    Jacob Sampson Guest

    How to limit AD search to just servers.

    Below is the script I use to find all computers in AD. How can I limit it to
    just servers. I tried replacing the word computer with server but no luck.



    $root = [ADSI]''

    $searcher = new-object System.DirectoryServices.DirectorySearcher($root)

    $searcher.filter = "(objectCategory=computer)"

    $searcher.pageSize=1000

    $searcher.propertiesToLoad.Add("name")

    $computers = $searcher.findall()

    Thanks for the support.
    Jacob Sampson

      My System SpecsSystem Spec

  2. #2


    PaulChavez Guest

    RE: How to limit AD search to just servers.

    You can check the operatingsystem or operatingsystemversion properties in
    your filter.

    Find all computers with "Server" in the operating system name:
    $searcher.filter = "(&(objectCategory=computer)(operatingsystem=*Server*))"


    Find only computers with server version 5.2 (3790):
    $searcher.filter = "(&(objectCategory=computer)(operatingsystemversion=5.2
    (3790)))"


      My System SpecsSystem Spec

How to limit AD search to just servers. problems?

Similar Threads
Thread Thread Starter Forum Replies Last Post
no logon servers available when connecting to most servers in trus 2010 Server General 1 16 Oct 2009
Windows Vista ultimate x64 Search engine issues - Search fails to index cprTodd Vista General 2 18 Jun 2009
search workstations and servers by os version drew PowerShell 6 27 Feb 2009
Search.All in AD (LDAP) found exactly 1000 - is this a built in limit? Bruce Sanderson PowerShell 0 29 Aug 2008
Changing Start Menu Search default selection from "Search the Com. =?Utf-8?B?R3JhbnQ=?= Vista file management 0 14 Jul 2006