Detect if your PowerShell code is running in Windows Terminal

Hi All,

Ever wanted to detect if your PowerShell Script is running in a WindowsTerminal Session?
As you can see, the default Font is a bit bigger than in the other PowerShell Windows

Here is some code to detect that

if ($env:WT_SESSION) {
    Write-Host "Windows Terminal detected"
} else {
    Write-Host "Windows Terminal not detected"
}


Windows Terminal


PowerShell 5


PowerShell 7


PowerShell ISE



Regards
Andres Bohren