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.
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?
What I have done is that, I push the IP Address into an Array, then have done a
foreach using this command line:
Which brings back the Computer Names.