How to determine if my PowerShell script is being executed by Windows Terminal?
问题 I want to do something special when my PowerShell script is being executed by Windows Terminal and not the normal PowerShell command line or ISE. How to determine that? I checked some built-in variables like $Host and can't find related information. 回答1: Disclaimer: Windows Terminal is still in development at this time of writing and this information could change for the stable release. Look for the $env:WT_SESSION environment variable - this looks to be set to a GUID in a Windows Terminal