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"
}
Write-Host "Windows Terminal detected"
} else {
Write-Host "Windows Terminal not detected"
}
Windows Terminal
![](https://icewolffile.blob.core.windows.net/$web/202204/PS_DetectWindowsTerminal_01.jpg)
PowerShell 5
![](https://icewolffile.blob.core.windows.net/$web/202204/PS_DetectWindowsTerminal_02.jpg)
PowerShell 7
![](https://icewolffile.blob.core.windows.net/$web/202204/PS_DetectWindowsTerminal_03.jpg)
PowerShell ISE
![](https://icewolffile.blob.core.windows.net/$web/202204/PS_DetectWindowsTerminal_04.jpg)
Regards
Andres Bohren
![](https://icewolffile.blob.core.windows.net/$web/logos/powershell_logo.png)