开发者

Search Entire Domain for File through Command prompt

开发者 https://www.devze.com 2023-03-05 12:53 出处:网络
Would there be a way to search an entire domain for a specific file through the command prompt. I am using dir/s E开发者_如何学JAVAxample.txt but of course that only searches one specific computer.Yo

Would there be a way to search an entire domain for a specific file through the command prompt.

I am using dir/s E开发者_如何学JAVAxample.txt but of course that only searches one specific computer.


You could get a list of computer objects from the domain using an LDAP query in a VBScript, then iterate through the list of computers using a For Each and then execute the dir /s command on each of the computers in turn and read the output from the command and parse your results to see if you get a hit.

It wouldn't be pretty but it'd work.

EDIT It'd use the credentials of whatever was running the executable at the time. Using WinNT is ok, but if you want to do it properly, use the DirectoryServices (I know it's C#, but you get the drift from there and can use this to convert) namespace.

Once you have your list of computers, you need to iterate through them and run your command/process against each computer.


One easy way would be to get a computer list, and then access them using the UNC path and the administrative shares ([driveletter]$). You would have to do this from an account with administrative access on all of the computers.

\\computer01\c$\windows

That would give you the windows folder on computer01. Throw that in a for-each loop, and do the searching as normal.

Also depending on the number of computers you are looking at, and the network conditions, you might be able to speed things up if you spawned a few worker threads.

0

精彩评论

暂无评论...
验证码 换一张
取 消