# Type of object to retrieve from AD $strCategory = "computer" # Set the domain to search to be the current domain $objDomain = New-Object System.DirectoryServices.DirectoryEntry # Find all the objects in the domain with the category of Computer $objSearcher = New-Object System.DirectoryServices.DirectorySearcher $objSearcher.SearchRoot = $objDomain $objSearcher.Filter = ("(objectCategory=$strCategory)") # Array of property types to retrieve $colProplist = "name", "location", "operatingSystem" foreach ($i in $colPropList) { $objSearcher.PropertiesToLoad.Add($i) } # Finds all the computers in the domain and # saves them to a collection $colResults = $objSearcher.FindAll() #move the Active Directory objects into my excel sheet $colResults | foreach-Object { $_.Properties.name }