Determine Domain and username used when a network share was mapped
Posted by jpluimers on 2016/11/15
Need to research this a bit further as this works:
powershell gwmi -Query 'Select LocalName, RemoteName, UserName from Win32_NetworkConnection'
__GENUS : 2
__CLASS : Win32_NetworkConnection
__SUPERCLASS :
__DYNASTY :
__RELPATH :
__PROPERTY_COUNT : 3
__DERIVATION : {}
__SERVER :
__NAMESPACE :
__PATH :
LocalName :
RemoteName : \\w701ujpl\IPC$
UserName : EN81ENTx64SCAN\jeroenp
PSComputerName :
But this fails for some Powershell versions:
powershell
gwmi -Query 'Select * from Win32_NetworkConnection' | Select-Object LocalName, RemoteName, UserName, ConnectionState | Sort-Object LocalName | ft -auto
–jeroen
Source: user – Determine Domain and username used to map a network drive – Stack Overflow






jpluimers said
Ondrej Kelle on G+ commented at https://plus.google.com/u/0/+JeroenPluimers/posts/jjng79B8ouf
WNetGetUser might work, I think.