Paebbels
Paebbels

Reputation: 16213

Is it possible to know if a PowerShell script is launched from GUI or console?

Is it possible to know if a PowerShell script is launched from GUI e.g. double-click in the explorer or manually in a powershell console?

I would like to use an interactive console mode if it's launched in GUI / explorer.

Upvotes: 2

Views: 202

Answers (1)

CB.
CB.

Reputation: 60910

Query $host automatic variable

$host.name

return the name of the actual host.

Upvotes: 3

Related Questions