PowerTip: Find Name of PowerShell Host

Doctor Scripto

Summary: Learn to find the name of the Windows PowerShell host.

Hey, Scripting Guy! Question How can I determine if I am running a Windows PowerShell script in the Windows PowerShell console?

Hey, Scripting Guy! Answer Use the Get-Host cmdlet. Here is how to check:

  if((Get-Host).name -ne "consolehost") {"Take appropriate action here"}


Discussion is closed.

Feedback usabilla icon