en-US/TerminalSessions.dll-Help.xml
|
<?xml version="1.0" encoding="utf-8"?>
<helpItems xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" schema="maml" xmlns="http://msh"> <command:command> <command:details> <command:name>Get-WTSClientInfo</command:name> <maml:description> <maml:para>Retrieves client information for a session on a Windows host. ## DESCRIPTION The Get-WTSClientInfo cmdlet retrieves detailed client connection information for a specific Terminal Services session using the WTSQueryClientInfo API. This includes client computer details, display settings, encryption level, network information, and device identifiers.</maml:para> </maml:description> <command:verb>Get</command:verb> <command:noun>WTSClientInfo</command:noun> </command:details> <maml:description> <maml:para>The Get-WTSClientInfo cmdlet retrieves detailed client connection information for a specific Terminal Services session using the WTSQueryClientInfo API. This includes client computer details, display settings, encryption level, network information, and device identifiers.</maml:para> <maml:para>## SYNTAX</maml:para> <maml:para>``` Get-WTSClientInfo [-SessionInfo] <SessionInfo> [<CommonParameters>] ```</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Get-WTSClientInfo</maml:name> <command:parameter required="true" variableLength="false" globbing="false" pipelineInput="false" position="0" aliases="none"> <maml:name>SessionInfo</maml:name> <maml:description> <maml:para>Specifies the session information object to query. This parameter accepts SessionInfo objects from Get-WTSSession and is mandatory. The object must contain the ComputerName and SessionId properties.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="true">SessionInfo</command:parameterValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="true" variableLength="false" globbing="false" pipelineInput="false" position="0" aliases="none"> <maml:name>SessionInfo</maml:name> <maml:description> <maml:para>Specifies the session information object to query. This parameter accepts SessionInfo objects from Get-WTSSession and is mandatory. The object must contain the ComputerName and SessionId properties.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="true">SessionInfo</command:parameterValue> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <dev:name>PSWTSSession.SessionInfo</dev:name> </dev:type> <maml:description> <maml:para>You can pipe SessionInfo objects from Get-WTSSession to this cmdlet.</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <dev:name>PSWTSSession.ClientInfo</dev:name> </dev:type> <maml:description> <maml:para>Returns ClientInfo objects containing detailed client information including: - ClientName: Name of the client computer - Domain: Client's domain - UserName: User name on the client - WorkDirectory: Working directory - InitialProgram: Initial program to run - EncryptionLevel: Connection encryption level - ClientAddressFamily: Network protocol (IPv4/IPv6) - ClientAddress: IP address of the client - HRes/VRes: Horizontal and vertical display resolution - ColorDepth: Color depth in bits per pixel - ClientDirectory: Client directory path - ClientBuildNumber: Client OS build number - ClientHardwareId: Hardware identifier - ClientProductId: Product identifier - OutBufCountHost/OutBufCountClient: Output buffer counts - OutBufLength: Output buffer length - DeviceId: Device identifier</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para>This cmdlet requires administrative privileges to query session information. The ClientAddress property may be null for console sessions or if the connection doesn't provide IP information.</maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>--------- Example 1: Get client info for all remote sessions ---------</maml:title> <maml:introduction> <maml:para>```powershell Get-WTSSession | Where-Object ClientName -ne $null | Get-WTSClientInfo ```</maml:para> <maml:para>€</maml:para> <maml:para>This command retrieves client information for all remote desktop sessions (excluding console sessions).</maml:para> </maml:introduction> <dev:code /> <dev:remarks /> </command:example> <command:example> <maml:title>--------- Example 2: Get client info for a specific user ---------</maml:title> <maml:introduction> <maml:para>```powershell $session = Get-WTSSession | Where-Object UserName -eq "admin" Get-WTSClientInfo -SessionInfo $session ```</maml:para> <maml:para>€</maml:para> <maml:para>This command retrieves client connection details for a specific user's session.</maml:para> </maml:introduction> <dev:code /> <dev:remarks /> </command:example> <command:example> <maml:title>--------- Example 3: View client display resolution ---------</maml:title> <maml:introduction> <maml:para>```powershell Get-WTSSession | Get-WTSClientInfo | Select-Object ClientName, HRes, VRes, ColorDepth ```</maml:para> <maml:para>€</maml:para> <maml:para>This command displays the screen resolution and color depth settings for all client connections.</maml:para> </maml:introduction> <dev:code /> <dev:remarks /> </command:example> <command:example> <maml:title>--------- Example 4: Check client IP addresses ---------</maml:title> <maml:introduction> <maml:para>```powershell Get-WTSSession | Get-WTSClientInfo | Select-Object UserName, ClientName, ClientAddress ```</maml:para> <maml:para>€</maml:para> <maml:para>This command shows the IP address of each connected client.</maml:para> </maml:introduction> <dev:code /> <dev:remarks /> </command:example> <command:example> <maml:title>--------- Example 5: View encryption levels ---------</maml:title> <maml:introduction> <maml:para>```powershell Get-WTSSession | Get-WTSClientInfo | Select-Object UserName, EncryptionLevel, ClientAddressFamily ```</maml:para> <maml:para>€</maml:para> <maml:para>This command displays the encryption level and network protocol for each connection.</maml:para> </maml:introduction> <dev:code /> <dev:remarks /> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Get-WTSSession</maml:linkText> <command:uri>Get-WTSSession.md</command:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Get-WTSInfo</maml:linkText> <command:uri>Get-WTSInfo.md</command:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Remove-WTSSession</maml:linkText> <command:uri>Remove-WTSSession.md</command:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command> <command:details> <command:name>Get-WTSInfo</command:name> <maml:description> <maml:para>Retrieves detailed WTS information for a session on a Windows host.</maml:para> </maml:description> <command:verb>Get</command:verb> <command:noun>WTSInfo</command:noun> </command:details> <maml:description> <maml:para>The Get-WTSInfo cmdlet retrieves detailed Windows Terminal Services information for a specific session using the WTSQueryWTSINFO API. This includes connection state, byte and frame statistics, timing information, and session metadata.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Get-WTSInfo</maml:name> <command:parameter required="true" variableLength="false" globbing="false" pipelineInput="false" position="0" aliases="none"> <maml:name>SessionInfo</maml:name> <maml:description> <maml:para>Specifies the session information object to query. This parameter accepts SessionInfo objects from Get-WTSSession and is mandatory. The object must contain the ComputerName and SessionId properties.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="true">SessionInfo</command:parameterValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="true" variableLength="false" globbing="false" pipelineInput="false" position="0" aliases="none"> <maml:name>SessionInfo</maml:name> <maml:description> <maml:para>Specifies the session information object to query. This parameter accepts SessionInfo objects from Get-WTSSession and is mandatory. The object must contain the ComputerName and SessionId properties.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="true">SessionInfo</command:parameterValue> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <dev:name>PSWTSSession.SessionInfo</dev:name> </dev:type> <maml:description> <maml:para>You can pipe SessionInfo objects from Get-WTSSession to this cmdlet.</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <dev:name>PSWTSSession.WTSInfo</dev:name> </dev:type> <maml:description> <maml:para>Returns WTSInfo objects containing detailed session information including: - State: Connection state - SessionId: Unique session identifier - IncomingBytes/OutgoingBytes: Data transfer statistics - IncomingFrames/OutgoingFrames: Frame count statistics - IncomingCompressedBytes/OutgoingCompressedBy: Compression statistics - WinStationName: Name of the window station - Domain: User's domain - UserName: User's name - ConnectTime: When the session connected - DisconnectTime: When the session disconnected (if applicable) - LastInputTime: When the user last provided input - LogonTime: When the user logged on - CurrentTime: Current system time</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para>This cmdlet requires administrative privileges to query sessions. Some timing information may be null if not applicable to the session state.</maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>--------- Example 1: Get detailed info for all sessions ---------</maml:title> <maml:introduction> <maml:para>```powershell Get-WTSSession | Get-WTSInfo ```</maml:para> <maml:para>€</maml:para> <maml:para>This command retrieves detailed information for all sessions on the local computer by piping session objects to Get-WTSInfo.</maml:para> </maml:introduction> <dev:code /> <dev:remarks /> </command:example> <command:example> <maml:title>--------- Example 2: Get info for a specific session ---------</maml:title> <maml:introduction> <maml:para>```powershell $session = Get-WTSSession | Where-Object UserName -eq "john.doe" Get-WTSInfo -SessionInfo $session ```</maml:para> <maml:para>€</maml:para> <maml:para>This command retrieves detailed information for a specific user's session.</maml:para> </maml:introduction> <dev:code /> <dev:remarks /> </command:example> <command:example> <maml:title>--------- Example 3: View session timing information ---------</maml:title> <maml:introduction> <maml:para>```powershell Get-WTSSession | Get-WTSInfo | Select-Object UserName, LogonTime, ConnectTime, LastInputTime ```</maml:para> <maml:para>€</maml:para> <maml:para>This command retrieves timing information for all sessions, showing when users logged on, connected, and last provided input.</maml:para> </maml:introduction> <dev:code /> <dev:remarks /> </command:example> <command:example> <maml:title>--------- Example 4: Check session bandwidth usage ---------</maml:title> <maml:introduction> <maml:para>```powershell Get-WTSSession | Get-WTSInfo | Select-Object UserName, IncomingBytes, OutgoingBytes, @{N="TotalMB";E={($_.IncomingBytes + $_.OutgoingBytes)/1MB}} ```</maml:para> <maml:para>€</maml:para> <maml:para>This command displays bandwidth usage statistics for all sessions, calculating the total data transferred in megabytes.</maml:para> </maml:introduction> <dev:code /> <dev:remarks /> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Get-WTSSession</maml:linkText> <command:uri>Get-WTSSession.md</command:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Get-WTSClientInfo</maml:linkText> <command:uri>Get-WTSClientInfo.md</command:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Remove-WTSSession</maml:linkText> <command:uri>Remove-WTSSession.md</command:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command> <command:details> <command:name>Get-WTSSession</command:name> <maml:description> <maml:para>Enumerates sessions on Windows Terminal Services hosts.</maml:para> </maml:description> <command:verb>Get</command:verb> <command:noun>WTSSession</command:noun> </command:details> <maml:description> <maml:para>The Get-WTSSession cmdlet retrieves all active and disconnected sessions on one or more Windows Terminal Services hosts. It uses the WTSEnumerateSessionsExW API to query session information including session ID, state, user name, domain, and client information.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Get-WTSSession</maml:name> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="0" aliases="none"> <maml:name>ComputerName</maml:name> <maml:description> <maml:para>Specifies one or more computer names to query for sessions. If not specified or set to an empty array, the cmdlet queries the local computer. You can specify multiple computer names separated by commas or pass them through the pipeline.</maml:para> </maml:description> <command:parameterValue required="false" variableLength="true">String[]</command:parameterValue> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="Named" aliases="none"> <maml:name>Detailed</maml:name> <maml:description> <maml:para>When specified, retrieves additional session details including idle time and logon time. This provides more comprehensive information about each session but may take slightly longer to execute.</maml:para> </maml:description> <command:parameterValue required="false" variableLength="true">SwitchParameter</command:parameterValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="0" aliases="none"> <maml:name>ComputerName</maml:name> <maml:description> <maml:para>Specifies one or more computer names to query for sessions. If not specified or set to an empty array, the cmdlet queries the local computer. You can specify multiple computer names separated by commas or pass them through the pipeline.</maml:para> </maml:description> <command:parameterValue required="false" variableLength="true">String[]</command:parameterValue> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="Named" aliases="none"> <maml:name>Detailed</maml:name> <maml:description> <maml:para>When specified, retrieves additional session details including idle time and logon time. This provides more comprehensive information about each session but may take slightly longer to execute.</maml:para> </maml:description> <command:parameterValue required="false" variableLength="true">SwitchParameter</command:parameterValue> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <dev:name>System.String</dev:name> </dev:type> <maml:description> <maml:para>You can pipe computer names to this cmdlet.</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <dev:name>PSWTSSession.SessionInfo</dev:name> </dev:type> <maml:description> <maml:para>Returns SessionInfo objects by default, containing session ID, state, session name, user name, domain name, computer name, and client name.</maml:para> </maml:description> </command:returnValue> <command:returnValue> <dev:type> <dev:name>PSWTSSession.SessionInfoExtra</dev:name> </dev:type> <maml:description> <maml:para>Returns SessionInfoExtra objects when -Detailed is specified, containing all SessionInfo properties plus idle time and logon time.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para>This cmdlet requires administrative privileges to query remote computers. Ensure you have the necessary permissions before running this cmdlet against remote systems.</maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>--------- Example 1: Get all sessions on the local computer ---------</maml:title> <maml:introduction> <maml:para>```powershell Get-WTSSession ```</maml:para> <maml:para>€</maml:para> <maml:para>This command retrieves all sessions on the local computer.</maml:para> </maml:introduction> <dev:code /> <dev:remarks /> </command:example> <command:example> <maml:title>--------- Example 2: Get sessions from multiple computers ---------</maml:title> <maml:introduction> <maml:para>```powershell Get-WTSSession -ComputerName "Server01", "Server02" ```</maml:para> <maml:para>€</maml:para> <maml:para>This command retrieves sessions from two remote computers named Server01 and Server02.</maml:para> </maml:introduction> <dev:code /> <dev:remarks /> </command:example> <command:example> <maml:title>--------- Example 3: Get sessions with detailed information ---------</maml:title> <maml:introduction> <maml:para>```powershell Get-WTSSession -Detailed ```</maml:para> <maml:para>€</maml:para> <maml:para>This command retrieves all sessions on the local computer with additional details including idle time and logon time.</maml:para> </maml:introduction> <dev:code /> <dev:remarks /> </command:example> <command:example> <maml:title>--------- Example 4: Get sessions from pipeline ---------</maml:title> <maml:introduction> <maml:para>```powershell "Server01", "Server02", "Server03" | Get-WTSSession ```</maml:para> <maml:para>€</maml:para> <maml:para>This command retrieves sessions from multiple computers passed through the pipeline.</maml:para> </maml:introduction> <dev:code /> <dev:remarks /> </command:example> <command:example> <maml:title>--------- Example 5: Filter disconnected sessions ---------</maml:title> <maml:introduction> <maml:para>```powershell Get-WTSSession | Where-Object State -eq Disconnected ```</maml:para> <maml:para>€</maml:para> <maml:para>This command retrieves all disconnected sessions on the local computer.</maml:para> </maml:introduction> <dev:code /> <dev:remarks /> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Get-WTSInfo</maml:linkText> <command:uri>Get-WTSInfo.md</command:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Get-WTSClientInfo</maml:linkText> <command:uri>Get-WTSClientInfo.md</command:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Remove-WTSSession</maml:linkText> <command:uri>Remove-WTSSession.md</command:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command> <command:details> <command:name>Remove-WTSSession</command:name> <maml:description> <maml:para>Removes (logs off) a session from a Windows host.</maml:para> </maml:description> <command:verb>Remove</command:verb> <command:noun>WTSSession</command:noun> </command:details> <maml:description> <maml:para>The Remove-WTSSession cmdlet logs off a user session on a Windows Terminal Services host using the WTSLogoffSession API. This cmdlet supports ShouldProcess, so it will prompt for confirmation before logging off sessions. The confirmation impact is set to High due to the disruptive nature of logging off users.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Remove-WTSSession</maml:name> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="Named" aliases="none"> <maml:name>Confirm</maml:name> <maml:description> <maml:para>Prompts you for confirmation before running the cmdlet. By default, this cmdlet will prompt for confirmation due to the high impact of logging off user sessions.</maml:para> </maml:description> <command:parameterValue required="false" variableLength="true">SwitchParameter</command:parameterValue> </command:parameter> <command:parameter required="true" variableLength="false" globbing="false" pipelineInput="false" position="0" aliases="none"> <maml:name>SessionInfo</maml:name> <maml:description> <maml:para>Specifies the session information object to log off. This parameter accepts SessionInfo objects from Get-WTSSession and is mandatory. The object must contain the ComputerName, SessionId, UserName, and State properties.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="true">SessionInfo</command:parameterValue> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="Named" aliases="none"> <maml:name>WaitForLogoff</maml:name> <maml:description> <maml:para>When specified, the cmdlet waits for the logoff operation to complete before returning. Without this switch, the logoff is initiated asynchronously and the cmdlet returns immediately.</maml:para> </maml:description> <command:parameterValue required="false" variableLength="true">SwitchParameter</command:parameterValue> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="Named" aliases="none"> <maml:name>WhatIf</maml:name> <maml:description> <maml:para>Shows what would happen if the cmdlet runs. The cmdlet is not run.</maml:para> </maml:description> <command:parameterValue required="false" variableLength="true">SwitchParameter</command:parameterValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="Named" aliases="none"> <maml:name>Confirm</maml:name> <maml:description> <maml:para>Prompts you for confirmation before running the cmdlet. By default, this cmdlet will prompt for confirmation due to the high impact of logging off user sessions.</maml:para> </maml:description> <command:parameterValue required="false" variableLength="true">SwitchParameter</command:parameterValue> </command:parameter> <command:parameter required="true" variableLength="false" globbing="false" pipelineInput="false" position="0" aliases="none"> <maml:name>SessionInfo</maml:name> <maml:description> <maml:para>Specifies the session information object to log off. This parameter accepts SessionInfo objects from Get-WTSSession and is mandatory. The object must contain the ComputerName, SessionId, UserName, and State properties.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="true">SessionInfo</command:parameterValue> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="Named" aliases="none"> <maml:name>WaitForLogoff</maml:name> <maml:description> <maml:para>When specified, the cmdlet waits for the logoff operation to complete before returning. Without this switch, the logoff is initiated asynchronously and the cmdlet returns immediately.</maml:para> </maml:description> <command:parameterValue required="false" variableLength="true">SwitchParameter</command:parameterValue> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="Named" aliases="none"> <maml:name>WhatIf</maml:name> <maml:description> <maml:para>Shows what would happen if the cmdlet runs. The cmdlet is not run.</maml:para> </maml:description> <command:parameterValue required="false" variableLength="true">SwitchParameter</command:parameterValue> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <dev:name>PSWTSSession.SessionInfo</dev:name> </dev:type> <maml:description> <maml:para>You can pipe SessionInfo objects from Get-WTSSession to this cmdlet.</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <dev:name>System.Management.Automation.PSObject</dev:name> </dev:type> <maml:description> <maml:para>Returns a custom object containing: - SessionId: The session ID that was logged off - UserName: The user name of the logged off session - ComputerName: The computer where the session was logged off - State: The state of the session before logoff - Result: Boolean indicating success (True) or failure (False)</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para>This cmdlet requires administrative privileges to log off sessions. Use with caution as it will forcefully disconnect users and may result in data loss if users have unsaved work. The cmdlet prompts for confirmation by default to prevent accidental logoffs.</maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>--------- Example 1: Log off a specific session ---------</maml:title> <maml:introduction> <maml:para>```powershell Get-WTSSession | Where-Object UserName -eq "john.doe" | Remove-WTSSession ```</maml:para> <maml:para>€</maml:para> <maml:para>This command logs off all sessions for user "john.doe" after prompting for confirmation.</maml:para> </maml:introduction> <dev:code /> <dev:remarks /> </command:example> <command:example> <maml:title>--------- Example 2: Log off all disconnected sessions ---------</maml:title> <maml:introduction> <maml:para>```powershell Get-WTSSession | Where-Object State -eq Disconnected | Remove-WTSSession -Confirm:$false ```</maml:para> <maml:para>€</maml:para> <maml:para>This command logs off all disconnected sessions without prompting for confirmation.</maml:para> </maml:introduction> <dev:code /> <dev:remarks /> </command:example> <command:example> <maml:title>--------- Example 3: Log off and wait for completion ---------</maml:title> <maml:introduction> <maml:para>```powershell $session = Get-WTSSession | Where-Object SessionId -eq 5 Remove-WTSSession -SessionInfo $session -WaitForLogoff ```</maml:para> <maml:para>€</maml:para> <maml:para>This command logs off session ID 5 and waits for the logoff operation to complete before continuing.</maml:para> </maml:introduction> <dev:code /> <dev:remarks /> </command:example> <command:example> <maml:title>--------- Example 4: Preview what would be logged off ---------</maml:title> <maml:introduction> <maml:para>```powershell Get-WTSSession | Where-Object State -ne Active | Remove-WTSSession -WhatIf ```</maml:para> <maml:para>€</maml:para> <maml:para>This command shows what sessions would be logged off without actually performing the logoff operation.</maml:para> </maml:introduction> <dev:code /> <dev:remarks /> </command:example> <command:example> <maml:title>--------- Example 5: Force log off multiple sessions ---------</maml:title> <maml:introduction> <maml:para>```powershell Get-WTSSession -ComputerName "Server01" | Where-Object {$_.IdleTime -gt (New-TimeSpan -Hours 8)} | Remove-WTSSession -Confirm:$false ```</maml:para> <maml:para>€</maml:para> <maml:para>This command forcefully logs off all sessions on Server01 that have been idle for more than 8 hours.</maml:para> </maml:introduction> <dev:code /> <dev:remarks /> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Get-WTSSession</maml:linkText> <command:uri>Get-WTSSession.md</command:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Get-WTSInfo</maml:linkText> <command:uri>Get-WTSInfo.md</command:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Get-WTSClientInfo</maml:linkText> <command:uri>Get-WTSClientInfo.md</command:uri> </maml:navigationLink> </command:relatedLinks> </command:command> </helpItems> |