Test Console
Last Modified: February 25, 2024 18:18 CEST

Test-Console #

SYNOPSIS #

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

SYNTAX #

Test-Console [-ProgressAction <ActionPreference>] [<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 #