Solved

Is there a VB script to locate one or more home directories for a user?

Posted on 2011-03-25
8
256 Views
Last Modified: 2012-05-11
Is there a way, either VB script or batch file, to locate one or more home directories for a user?  

For example, my LAN ID, qnguye01, is found on two Windows file cluster nodes.  I want to be able to run a VB script or batch file to locate other end users' home directories, if they have one or more floating around somewhere.

TY,
Quan
0
Comment
Question by:qvn7
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 5

Expert Comment

by:xylog
ID: 35221914
This will return the home directory that is set in active directory:

dsquery user -samid usernam|dsget user -hmdir

0
 
LVL 46

Expert Comment

by:aikimark
ID: 35222074
where will this script run?
0
 

Author Comment

by:qvn7
ID: 35222598
@ xylog:

Thanks, but what I need is to locate other home directories that isn't the main one under the "Profile" tab in Active Directory.  

My main home directory folder is located here:

\\HomeServer1\SharedDrive1\SharedVol1\qnguye01

I recently found out that I had another one located somewhere else, like:

\\HomeServer3\SharedDrive4\SharedVol3\qnguye01

Is there a way to locate multiple home directories either using VB script, batch file or dsquery commands?

Thanks!!!
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:qvn7
ID: 35222599
@ aikimark

Where will this script run?  Either my primary workstation or one of the file servers hosting the home directories data.
0
 
LVL 5

Expert Comment

by:xylog
ID: 35222798
If you want to locate a directory with a specific name in a specified location you can use a series of "if exist" statements in a batch file:

findhomes.bat
==========
@echo off
if exist \\HomeServer1\SharedDrive1\SharedVol1\%1 echo \\HomeServer1\SharedDrive1\SharedVol1\%1

if exist \\HomeServer3\SharedDrive4\SharedVol3\%1 echo \\HomeServer3\SharedDrive4\SharedVol3\%1

===========

to run:

findhomes qnguye01

Alternatively if you want to search the entire hard drive you can enumerate all the directories with a dir statement:

dir /ad /s |findstr qnguye01

This is a bit slow if you have many directories (say, more than several hundred)

There is a middle ground if you have many volumes you can loop thru them like so:

for /d %%i in (\\HomeServer1\SharedDrive1\*) do if exist  %%i\%1 echo %%i\%1

If you have multiple shares we can loop thru them with the net view command. For multiple servers best bet is to loop thru a list in a text file.
0
 
LVL 14

Accepted Solution

by:
yehudaha earned 500 total points
ID: 35226366
hello

edit line 1 to add your home folder server names

when it's ask for folder name you can input "like" name input, what do i mean:

if you look for " jack" folder but you not sure if there addition to the name like: "jackfolder".
you can put just jack and the script will search for any folder have jack in the name.
ArrComputers = Array("homeserver1,homeserver2")

dir = InputBox("Enter Directory Name")

For Each strComputer In ArrComputers
Set objWMIService = GetObject _
    ("winmgmts:" & "!\\" & strComputer & "\root\cimv2")
Set colFolders = objWMIService.ExecQuery _
   ("Select * From Win32_Directory Where name Like '%\\" & Dir & "%'")
   
For Each objFolder in colFolders
    Wscript.Echo "Found: " & objFolder.Name & " ON " & strComputer
Next
Next

MsgBox "done"

Open in new window

0
 

Author Comment

by:qvn7
ID: 35233004
Thanks for ALL of your help!!!  Have a good day!!!
0
 
LVL 14

Expert Comment

by:yehudaha
ID: 35234373
great, please close the question and choose the answer/s you like
0

Featured Post

Ready to get started with anonymous questions?

It's easy! Check out this step-by-step guide for asking an anonymous question on Experts Exchange.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Welcome back!  My apologies for taking so long to write part two of this series; it's been a long time coming!  As I promised in Part 1, this article will focus on how to locate those elusive AD properties that you are searching for.  Why is this us…
When it comes to writing scripts for a Client/Server computing environment it is essential to consider some way of enabling the authentication functionality within a script. This sort of consideration mainly comes into the picture when we are dealin…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question