Comme je ne pouvais intervenir via la GPO, j'ai du trouver un script pour cette opération. Je n'avais pas le menu collection.
$server = "localhost";
# Get all RDP sessions
$sessions = query user /server:$server | select -skip 1;
# Loop through each session/line returned
foreach ($line in $sessions) {
$line = -split $line;
# Check for missing SessionName field/column
if ($line.length -eq 8) {
# Get current session state (column 4)
$state = $line[3];
# Get Session ID (column 3) and current idle time (column 5)
$sessionid = $line[2];
$idletime = $line[4];
} else {
# Get current session state (column 3)
$state = $line[2];
# Get Session ID (column 2) and current idle time (column 4)
$sessionid = $line[1];
$idletime = $line[3];
}
# If the session state is Disconnected
if ($state -ne "Actif") {
# Check if idle for more than 1 day (has a '+') and log off
if ($idletime -like "*+*") {
logoff $sessionid /server:$server /v
# Check if idle for more than 1 hour (has a ':') and log off
} elseif ($idletime -like "*:*") {
logoff $sessionid /server:$server /v
}
}
}