如何从HPC群集获取完整的作业名称

时间:2018-07-22 14:14:07

标签: powershell hpc

我需要从HPC culster获取职位名称。 我正在通过Powershell运行此命令:

Hpc>powershell -command "& {&'Add-PSSnapIn' Microsoft.HPC}"; "& {&'Get-HpcJob' -Scheduler il-winhpc4}"

我得到了列表,但是不管我做什么-名称仅是字符长,而不是全名。 有任何想法吗?

Id       Name       State           Owner                Priority        NumberOfTask                                                              s
--       ----       -----           -----                --------        ------------
5323613  Deploy ... Running         WINHPC4\tfsbuild                     30
5323614  Deploy ... Running         WINHPC4\tfsbuild                     30
5323643  Deploy ... Running         WINHPC4\tfsbuild                     30

1 个答案:

答案 0 :(得分:1)

如此处的详细说明:https://poshoholic.com/2010/11/11/powershell-quick-tip-creating-wide-tables-with-powershell/一样,PowerShell输出格式化程序将尝试获取您的输出并使其适合控制台,以供您阅读。

您可以通过以下三个主要选项进行更改: Format-Table -AutoSize | Out-String -Width nnnnFormat-ListConvertTo-Json

输出字符串:

powershell -command "Add-PSSnapIn Microsoft.HPC; Get-HpcJob -Scheduler il-winhpc4 | Format-Table -Auto | Out-String -Width 4000"

# The same kind of table you have, but with horizontal scrolling.

格式列表:

powershell -command "Add-PSSnapIn Microsoft.HPC; Get-HpcJob -Scheduler il-winhpc4 | Format-List"

Id: 5323613
Name: Deploy thing to place
State: running

ConvertTo-Json(或其他机器可读格式,如XML):

powershell -command "Add-PSSnapIn Microsoft.HPC; Get-HpcJob -Scheduler il-winhpc4 | ConvertTo-Json"

[
    {
        "Id": 5323613,
        "Name": "Deploy thing to place",
        "State": "Running"
    },
    ..
]

这是假设您需要所有其他信息。如果您不这样做,也许您可​​以这样做:

powershell -command "Add-PSSnapIn Microsoft.HPC; Get-HpcJob -Scheduler il-winhpc4 | Select-Object Id, Name"

powershell -command "Add-PSSnapIn Microsoft.HPC; Get-HpcJob -Scheduler il-winhpc4 | Select-Object -ExpandProperty Name"

NB。您不需要像&{&'';&{&'那样多的东西。我想您根本不需要任何东西。