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"}

0 comments

Discussion is closed.

Feedback usabilla icon