0

In AD we have Home Directory setup, and it points to a File Server which the folder it their [username]. I would like to know who is connect to those Home Directories by Computer Name by using Powershell.

I type person [username] in and it will display back which computers are connected to that folder.

I looked around in Get-ADuser but didn't find much and tried looking for commands but I could be looking it up wrong.

Thank you

[EDIT01]

I found that Get-WmiObject Win32_serverConnection brings back who is connected to the HomeDirectory using their USERNAME. The command I use is the following:

Get-WmiObject Win32_ServerConnection -ComputerName SERVER | where username -match "USER" | where sharename -like "home" | select username, sharename, computername | sort sharename | Format-Table -AutoSize

Which brings back a formatted table like this:

username sharename computername
-------- --------- ------------
USER     home      123.456.789.01
USER     home      123.456.789.02

Now the only problem I have is, it is not bringing back the ComputerName but the IP Address. I can manually nslookup and it will bring the ComputerName back but HOW DO I INTEGRATE that into the this command line?

[EDIT02]

What I have done is that, I push the IP Address into an Array, then have done a foreach using this command line:

([System.Net.DNS]::GetHostByAddress($ipaddress)).HostName

Which brings back the Computer Names.

0
Get-ADUser -SearchBase "OU=Path,OU=To,OU=OrgUnit,DC=domain,DC=com" -Filter {HomeDirectory -like 'C:\*'} -Properties HomeDirectory

Use the -filter and -Properties parameters to include the HomeDirectory property. Adjust the {HomeDirectory -like 'C:\*'} path to your valid location, same goed for the -SearchBase parameter.

  • The above command brings information but doesn't bring back on which Computer is connected to the HomeDirectory I found that Get-WmiObject Win32_ServerConnection brings back on what I want but doesn't nslookup the IP. Get-WmiObject Win32_ServerConnection -ComputerName FILESERVER | where username -match "USERNAME" | where sharename -like "home" | select username, sharename, computername | sort sharename | Format-Table -AutoSize – K2Chris1983 Mar 30 '16 at 13:10

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.