Test Console
Last Modified: May 3, 2023 13:53 CEST

Test-Console #

SYNOPSIS #

Tests whether the current PowerShell session is running in a console or RDP session.

SYNTAX #

Test-Console [<CommonParameters>]

DESCRIPTION #

The Test-Console function tests whether the current PowerShell session is running in a console or RDP session by checking the Win32_LogonSession class for RDP sessions. If an RDP session is detected, the function returns False. Otherwise, it returns True.

EXAMPLES #

Example 1: Tests PowerShell runs in a physical console #

PS C:\> Test-Console

Test whether the current PowerShell session is running in a console or RDP session.

PARAMETERS #

CommonParameters #

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

INPUTS #

None #

OUTPUTS #

System.Boolean #

NOTES #