简体   繁体   English

是否可以知道从GUI或控制台启动了PowerShell脚本?

[英]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 eg double-click in the explorer or manually in a powershell console? 是否可以知道是从GUI启动PowerShell脚本,例如在资源管理器中双击还是在Powershell控制台中手动启动?

I would like to use an interactive console mode if it's launched in GUI / explorer. 如果要在GUI /资源管理器中启动,我想使用交互式控制台模式。

Query $host automatic variable 查询$host自动变量

$host.name

return the name of the actual host. 返回实际主机的名称。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM