Ever have to migrate a share? Or see who is still accessing a share you need to do work on and want to make sure everyone is off of it so the user doesn’t lose any data? Here is the perfect one liner.
Get-wmiobject -computername ServerName win32_serverconnection | select-object sharename,username,computername
All you have to do is put your Server name in and then this will show all shares that users are connected to with their computer name. You could run it right on your server you want to check the shares on as well. This has been super helpful when doing maintenance and when we’ve had to migrate storage to different servers/locations.
Microsoft Learn:
Get-wmiobject