I converted the VBS to Powershell. It runs but I don't have a good test environment. You will have to test/fix/enhance to suit your needs.
$sess = Get-CimInstance Win32_LogonSession | Where-Object {($_.LogonType -eq 2) -or ($_.LogonType -eq 10)}
$results =@()
foreach ($s in $sess) {
$q = "Associators of {Win32_LogonSession.LogonId=" + $s.LogonId + "} Where AssocClass=Win32_LoggedOnUser Role=Dependent"
Get-CimInstance -Query $q | foreach {
$results += [PSCustomObject]@{
Computer = $env:COMPUTERNAME;
LogonId = $s.LogonId;
Type = $s.LogonType;
StartTime = $s.StartTime;
Domain = $_.Domain;
User = $_.Name;
Fullname = $_.Fullname
}
}
}
$results | Format-Table