Você precisa usar classe Win32_ServerConnection para isso.
No Powershell, você pode obter a lista de sessões classificadas por compartilhamentos com:
Get-WmiObject win32_serverconnection -computername $computername | Select username, computername, sharename | sort sharename
Função pronta para você:
Function Get-ServerConnection {
Param (
$ComputerName = 'localhost',
$account = '') # if empty, it means all accounts
# Now get the connections from that account
if ($account = '' )
{
Get-WmiObject win32_serverconnection -computername $computername | Select username, computername, sharename | ft -a
}
else
{Get-WmiObject win32_serverconnection -computername $computername | where username -match $account | select username,computername,sharename | sort username
}
}
Get-ServerConnection