# --------------------------------------------------------------------------------------------------- # # Microsoft PowerShell Source File # NAME: FindPre2K3.ps1 # # AUTHOR: Adam Bell, www.leadfollowmove.com # DATE : 12/03/2007 # # COMMENT: Best viewed in Notepad2 # # --------------------------------------------------------------------------------------------------- # --------------------------------------------------------------------------------------------------- function Find-Pre2K3 # --------------------------------------------------------------------------------------------------- { # Inputs: 1) None # Objective: 1) Search the Domain Controllers OU for DC's that are NOT Windows 2003 Servers. # Returns: 1) Writes to the screen each DN that matches the search criteria Param() $query = new-object system.directoryservices.directorysearcher $root = [adsi]"" $ou = [adsi]("LDAP://ou=Domain Controllers,"+$root.distinguishedName) $query.SearchRoot = $ou $query.filter = "(&(ObjectClass=computer)(operatingSystemVersion=4*)(userAccountControl:1.2.840.113556.1.4.803:=8192))" $query.SearchScope = "OneLevel" $result = $query.FindAll() if ($result -eq $null) { return $null } else { foreach ($machine in $result) { $ADobject = $machine.GetDirectoryEntry() write-host $ADobject.distinguishedName } } } # --------------------------------------------------------------------------------------------------- # Example calling statement: Find-Pre2K3