Created
August 29, 2016 09:18
-
-
Save Albus/0f203448a299cedf9103a6593045cb9d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ConnectionBroker = "srv-ts-04.fc-moron.ru" | |
$AllSessions = Get-RDUserSession -ConnectionBroker $ConnectionBroker | |
if($AllSessions -eq $null){ | |
[System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") | Out-Null | |
$Title = "Просмотр терминальных сессий" | |
$Message = "Не найдено ни одной сессии" | |
$Buttons = [System.Windows.Forms.MessageBoxButtons]::OK | |
$Icon = [System.Windows.Forms.MessageBoxIcon]::Exclamation | |
[System.Windows.Forms.MessageBox]::Show($Message,$Title,$Buttons,$Icon) | |
return | |
} | |
$ActiveSessions = $AllSessions | Where-Object -Property SessionState -EQ "STATE_ACTIVE" | |
$GridView = $ActiveSessions | Select-Object -Property CollectionName,UserName,CreateTime,HostServer,SessionID | |
$Session = $GridView | Out-GridView -Title "Просмотр терминальных сессий" -OutputMode Single | |
if($Session -eq $null){ | |
# No session selected, user probably clicked Cancel | |
return | |
} | |
mstsc /v:($Session.HostServer) /shadow:($Session.SessionId) /noConsentPrompt| Out-Null |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment