Categorii
Cum sa

Logout Disconnected Remote User Sessions

O varianta este cu un script powershell care il putem rula cu Scheduler in fiecare noapte.
Script-ul powershell:

Write-Host "Ending All Disconnected Remote User Sessions"
$RDSessions = Get-RDUserSession | Where-Object -Filter {$_.SessionState -eq 'STATE_DISCONNECTED'}
If (!$RDSessions){
Write-Output "No Remote User Sessions found "
} Else {
Foreach ($RDSession in $RDSessions){
Invoke-RDUserLogoff -UnifiedSessionID $RDSession.SessionId -HostServer $RDSession.HostServer -Force
Write-Output "The user" $RDSession.UserName "is logged off from" $RDSession.HostServer "server"
}
}

La actiuni Program/Script: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
Iar la parametri(arguments): C:\scripts\logoff-disconnected.ps1 – script-ul de mai sus.

Bifam si „Run with highest privileges”

Lasă un răspuns

Adresa ta de email nu va fi publicată. Câmpurile obligatorii sunt marcate cu *