将流程列表转换为HTML仅显示单个流程

时间:2017-01-05 15:39:37

标签: windows powershell-v2.0

我有一个包含两个变量的PowerShell脚本:

  1. $d:Array:获取每个进程的TCP连接,Just(ID)。
  2. $gns:获取变量$d中每个流程的名称。
  3. $d = @(Get-NetTCPConnection | Select -Expand OwningProcess)
    foreach ($s in $d) {
      $gns = Get-Process | Where-Object {$_.Id -eq $s} | Select -Expand Name
    }
    
    ConvertTo-HTML -PostContent $gns | Out-File c:\temp\TableHTML.html
    Invoke-Item c:\temp\TableHTML.html
    

    结果:

    enter image description here

    如您所见,结果只显示一个进程名称,这是错误的! 我想在结果中显示所有进程名称。

0 个答案:

没有答案