I am stomped right now. I am trying to search computers in a specific OU that may have a set of files. Then send this list to a text file.
The problem occurs when the search is executed and the results are stored. They are stored in ADSPATH only, and since I have a variable holding the search results, it is only holding the ADSPATH.
I then call to that variable in a test-path but I get errors saying that the FDQN is too long. I know why, its because the whole ADSPATH is being stuck in the "\\RIGH-HERE\Folderpath\file". Of course it won't work
I have done the code below, and I'm using the propertiesToLoad.Add("name"), but it feels like I am adding this to the results rather than sepcifying that only this be retrieved.
$objDomain = New-Object System.DirectoryServices.DirectoryEntry("LDAP://OU=Workstations,OU=Test,dc=xxx,dc=net")
$searcher = New-Object System.DirectoryServices.DirectorySearcher
$searcher.SearchRoot = $objDomain
$searcher.Filter = "(objectCategory=computer)"
$searcher.PageSize=1000
$searcher.SearchScope = "Subtree"
$searcher.propertiesToLoad.Add("name")
$computers = $searcher.findall()
$files = @("3fcv.ra", "ceg.sdr", "def.help", "fe.sp", "tfdse.xl")
$computers | foreach {
$TestPath = test-path "\\$computers\c$\Windows\system32\$files"
if ($TestPath -match "True") {out-file -filepath \\server\folder\virusPClist\list.txt}
}
If I comment out the $files array, and the $TestPath & if statement, and execute the $computers variable it lists only the ADSPATH in the results...Any help or guidance is very much appreciated. Thanks!!
This post has been edited by d4t4ch17d: 19 February 2009 - 11:24 AM

New Topic/Question
Reply



MultiQuote





|