PowerShell阵列格式表输出

问题描述 投票:0回答:1

我正在尝试将输出放入表格中,以使其看起来更整洁。任何帮助,将不胜感激。

我的代码


foreach($PC in $PCList) {
$GetPCUPTIME = $($PC.CN)

$PCInfo = Get-CimInstance Win32_OperatingSystem

$HotFix = Get-HotFix -ComputerName its-dracosvm2 -Credential $cred | #Need This and I should be able to get the KB's as well
 Select HotfixID, Description, InstalledOn |
 Sort-Object InstalledOn

$UpTime = $PCInfo.LocalDateTime.DayOfYear - $PCInfo.LastBootUpTime.DayOfYear
    if ($PC.OperatingSystem -like "*Server*") {
        $itemobject = New-Object –TypeName PSObject
            $itemobject | Add-Member –MemberType NoteProperty –Name "Server Name" -Value $PC.CN
            $itemobject | Add-Member –MemberType NoteProperty –Name "Operating System" -Value $PC.OperatingSystem
            $itemobject | Add-Member –MemberType NoteProperty –Name "Version" -Value $PC.OperatingSystemVersion
            $itemobject | Add-Member –MemberType NoteProperty –Name "Up Time" -Value $UpTime
            $itemobject | Add-Member –MemberType NoteProperty –Name "Hot Fixes" -Value $($HotFix)

            $newlist +=$itemobject

    }
}

我的输出在HotFix部分看来很好,那是所有东西都消失的地方。

输出The Current Output

任何帮助将不胜感激。

powershell formatting output
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.