clear-host
[string[]]$ComputerName = $env:COMPUTERNAME
$ServerObj = [adsi]"WinNT://$ComputerName/lanmanserver"
$objSessions = $ServerObj.PSBase.Invoke("Sessions")
foreach ($objSession in $objSessions){
Try
{
$Name = $objSession.GetType().InvokeMember("Name","GetProperty",$null,$objSession,$null)
$Computer= $objSession.GetType().InvokeMember("Computer","GetProperty",$null,$objSession,$null)
$User = $objSession.GetType().InvokeMember("User","GetProperty",$null,$objSession,$null)
$ConnectTime = $objSession.GetType().InvokeMember("ConnectTime","GetProperty",$null,$objSession,$null)
$IdleTime = $objSession.GetType().InvokeMember("IdleTime","GetProperty",$null,$objSession,$null)
#Stockage des informations
$prop = @{User = $Name
Path = $Computer
LockCount = $User
ConnectTime = $ConnectTime
IdleTime = $IdleTime
}
}
Catch
{
#catch exception
}
#write-host "$($prop.Path)`t$($prop.User)`t$($prop.LockCount)"
$prop
write-host ""
#write-host "$($Path)`t$($User)`t$($LockCount)"
}
Lien vers le fichier : cliquez ici
Article(s) suivant(s)
Article(s) précédent(s)