powershell - 为什么命令行执行与 powershell 中的脚本执行给出不同的结果

标签 powershell

在 powershell 命令提示符中运行以下命令可以正常工作:

Get-Service "my_service"
*output*
 Status   Name               DisplayName                           
------   ----               -----------                           
Running  my_service          My_SERVICE   

但是,如果按如下方式制作 ps1 scritp,我的输出不是我所期望的。

$my_service_check = Get-Service "my_service"
echo "My Service Status: $my_service_check"

*output*
my_service:  System.ServiceProcess.ServiceController 

为什么脚本不返回与命令相同的输出?

最佳答案

这是一个简单的:

echo "My Service Status:" $my_service_check

关于powershell - 为什么命令行执行与 powershell 中的脚本执行给出不同的结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58449667/

相关文章:

c# - PowerShell 能否在 GAC 中使用具有不同版本的本地程序集?

使用属性创建新 PSObject 的 PowerShell 最短语法?

powershell - 通过 PowerShell 在 IIS 中设置应用程序设置

powershell - 在Powershell中将输出写入文件时出现问题

json - Powershell:递归复制 JSON 属性

powershell - 如何从 Get-AzureRmResourceGroup 标签检索键值对

powershell - 即使 PS 脚本成功执行,Jenkins 作业也失败

c# - 从 C# 应用程序调用 azure powershell cmdlet 失败

python - Tcl 在我的 Python27 目录中似乎位于错误的位置。我怎样才能改变这个?

powershell - Get-AzurePublishSettingsFile 给出类未注册错误