[英]Powershell Tables & Counts
命令Get-RDUserSession為我提供了服務器連接用戶的完美視圖,甚至 Session State。 但我想將這些輸出分組到一個新變量中
我喜歡的是 Output
ServerName(this Should be Unieque)|TotalAmmountofConnected Users witch is an Adition of State_Active,State_Connected,Session_Disconnected
|SessionState(State_Active this in Count)| SessionState(State_Connected this in Count)| SessionState(State_Disconnected this in count)
我努力了:
$Value = Get-RDUserSession -CollectionName Colection -ConnectionBroker ConnectionBroker
$Value | Group-Object -Property ServerName,SessionState | Where-Object {$_.Count} | Select Name,Count
我不知道如何對這些值進行分組或將它們分開。 我真的需要一些幫助......
這是一個示例 Output:
ServerName SessionState
Server1.domain.com STATE_ACTIVE
Server1.domain.com STATE_ACTIVE
Server1.domain.com STATE_ACTIVE
Server1.domain.com STATE_ACTIVE
Server1.domain.com STATE_ACTIVE
Server1.domain.com STATE_ACTIVE
Server1.domain.com STATE_CONNECTED
Server3.domain.com STATE_ACTIVE
Server3.domain.com STATE_ACTIVE
Server3.domain.com STATE_DISCONNECTED
Server3.domain.com STATE_ACTIVE
Server3.domain.com STATE_CONNECTED
Server3.domain.com STATE_ACTIVE
Server3.domain.com STATE_ACTIVE
Server2.domain.com STATE_ACTIVE
Server2.domain.com STATE_CONNECTED
Server2.domain.com STATE_CONNECTED
Server2.domain.com STATE_CONNECTED
Server2.domain.com STATE_ACTIVE
Server7.domain.com STATE_ACTIVE
Server7.domain.com STATE_ACTIVE
Server7.domain.com STATE_DISCONNECTED
嘗試計算每個組的 Group 屬性中的屬性:
$Value = Get-RDUserSession -CollectionName Colection -ConnectionBroker ConnectionBroker
$Value |
sort ServerName |
Group ServerName |
Select Name,
@{l='TotalUsers'; e={($_.group.SessionState).count}},
@{l='ConnectedUsers'; e={($_.group.SessionState | where {$_ -like 'State_Active'}).count}},
@{l='DisconnectedUsers';e={($_.group.SessionState | where {$_ -like 'State_Disconnected'}).count}}
$Value = Get-RDUserSession -CollectionName Colection -ConnectionBroker ConnectionBroker
$Overview = $Value |
sort ServerName |
Group ServerName |
Select Name,
@{l='Total'; e={($_.group.SessionState).count}},
@{l='State_Active'; e={($_.group.SessionState | where {$_ -like 'State_Active'}).count}},
@{l='State_Connected';e={($_.group.SessionState | where {$_ -like 'State_Connected'}).count}},
@{l='State_Disconnected';e={($_.group.SessionState | where {$_ -like 'State_Disconnected'}).count}}
$overview | ft -AutoSize
謝謝!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.