【问题标题】:Converting output to HTML format in PowerShell在 PowerShell 中将输出转换为 HTML 格式
【发布时间】:2011-05-14 06:31:07
【问题描述】:

我正在学习 PowerShell。在我的实验中,我使用了以下命令:

PS C:\Windows\system32> gci -path C:\windows\  | Where-Object{$_.LastWriteTime -
gt "01-04-2011"} | Format-List -property Fullname | ConvertTo-Html | out-file E:
\PowerShell\Out.html

我希望输出类似于控制台中显示的输出(例如:FullName:C:\Windows...)。但是当我打开 Out.html 时,它有一些奇怪的东西,比如:

ClassId2e4f51ef21dd47e pageHeaderEntry pageFooterEntry autosizeInfo shapeInfo groupingEntry

我在这里错过了什么?

【问题讨论】:

  • 您是否应该使用Format-TableSelect-Object 代替Format-List?或者你应该在Where-Object之后直接附加ConvertTo-Html
  • 我也试过Format-Table..没有任何区别。
  • 尝试在where-object之后直接附加ConvertTo-Html
  • @empo:你是对的..我应该使用Format-List 而不是Select-Object。如果您可以将其发布为答案,我会接受。

标签: powershell


【解决方案1】:

使用select-object 代替format-list

【讨论】:

    【解决方案2】:
    【解决方案3】:
    cmd:
    powershell gci -path %windir% ^| ?{$_.LastWriteTime -gt (Get-Date -Year 2011 -Month 04 -Day 01)} ^| Format-List -property Fullname | more
    
    
    PS>gci -path %windir% | ?{$_.LastWriteTime -gt (Get-Date -Year 2011 -Month 04 -Day 01)} | Format-List -property Fullname | more
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-06-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-04-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多