Ogolnie mozna tak
QUERY USER /SERVER:localhost
LOGOFF SessionID /SERVER:localhost
LOGOFF SessionID /SERVER:localhost
Lub
function Get-TSSession([string]$UserName="\w"){ Write-Host "Server: Server1" query user /server:server1 | ?{$_ -match "username|no user exists|\b$UserName"} Write-Host "Server: Server2" query user /server:server2 | ?{$_ -match "username|no user exists|\b$UserName"} } function Clear-TSSession([string]$UserName){ Write-Host "Server: Server1" query user /server:Server1 | ?{$_ -match "\b$UserName\b"} | ?{$_ -match "rdp-tcp#\d*"} | %{logoff $matches[0] /server:server1} Write-Host "Server: Server2" query user /server:server2 | ?{$_ -match "\b$UserName\b"} | ?{$_ -match "rdp-tcp#\d*"} | %{logoff $matches[0] /server:server2} Write-Host "Clearing Record Locks" Clear-RecordLock($UserName) }
Brak komentarzy:
Prześlij komentarz