Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2012/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Powershell 是否计算属性以显示多个服务状态未工作?_Powershell - Fatal编程技术网

Powershell 是否计算属性以显示多个服务状态未工作?

Powershell 是否计算属性以显示多个服务状态未工作?,powershell,Powershell,我想知道如何更正以下计算的建筑红线: @{ n = 'DFS Service Status'; e = { (Get-Service -Name DFS* -ComputerName $ENV:ComputerName | FL ) } }, 结果是: DFS Service Status Microsoft.PowerShell.Commands.Internal.Format.FormatStartData Microsoft.PowerShell.Commands.Internal.Fo

我想知道如何更正以下计算的建筑红线:

@{ n = 'DFS Service Status'; e = { (Get-Service -Name DFS* -ComputerName $ENV:ComputerName | FL ) } },
结果是:

DFS Service Status
Microsoft.PowerShell.Commands.Internal.Format.FormatStartData Microsoft.PowerShell.Commands.Internal.Format.GroupStartData Microsoft.PowerShell.Commands.Internal.Format.FormatEntryData Microsoft.PowerShell.Commands.Internal.Format.FormatEntryData Microsoft.PowerShell.Commands.Internal.Format.GroupEndData Microsoft.PowerShell.Commands.Internal.Format.FormatEndData
根据项目事务处的意见:

我想得到'DisplayName-Status','DisplayName-Status'[…],因为我想转换HTML并以电子邮件的形式发送

记住这一点,您需要保留输入对象的属性,然后让
converttohtml
处理属性值的“字符串化”:

# ConvertTo-Html will inspect the input objects and use the `DisplayName` and `Status` 
# properties as column values in the HTML table
$html = Get-Service -Name DFS* |ConvertTo-Html -Property DisplayName,Status -Title "DFS Service Status" -As Table

# ...

Send-MailMessage ... -Body $html -BodyAsHtml

您希望输出是什么?如果服务正在运行,请更换
。|FL
|选择-Expand Status
猜测太多,请创建一个,另请参见:。是的,我想获得'DisplayName-Status','DisplayName-Status',…您肯定不想将原始字符串传输到
转换为HTML
谢谢!我感谢你在这件事上的帮助。