0

我为每个文件编写了一个文件,该文件将系统的 BIOS 信息存储在网络中,结果显示在我的控制台上,但我希望它们按顺序排列在 HTML 文件中。

代码:

  $arrComputers = get-Content -Path "C:\Computers.txt"
    foreach ($strComputer in $arrComputers)
    {
        $colItems = get-wmiobject -class "Win32_BIOS" -namespace "root\CIMV2" `
        -computername $strComputer
       foreach ($objItem in $colItems)
       {
         write-host "Computer Name: " $strComputer
          write-host "BIOS Version: " $objItem.BIOSVersion
      }

       $colItems1 = get-wmiobject -class Win32_logicaldisk -Filter "DeviceID = 'C:'" -computername $strComputer
       foreach ($objItem1 in $colItems1)
       {
        $e=$objItem1.freeSpace/1GB
         write-host "Total Space:  " $e
         }

        $colItems4 = Get-WMIObject -class Win32_PhysicalMemory  -computername $strComputer
      $colItems5=$colItems4 | Measure-Object -Property capacity -Sum 
      foreach ($objItem4 in $colItems5)
   {
      $e4=$colItems5.Sum/1GB
      write-host "Memory :  " $e4
   }


    }

你能帮我把以上所有数据保存在 HTML 中吗

4

1 回答 1

0

您需要查看ConvertTo-Htmlcmdlet。

Get-WmiObject -Class Win32_BIOS -ComputerName localhost,$env:COMPUTERNAME | 
Select PSComputerName,Version,SerialNumber | 
ConvertTo-Html | 
Out-File c:\test3.html

另一种基于 OPs 更新的方法:

$arrComputers = get-Content -Path "C:\Computers.txt"

$arrComputers | ForEach-Object { Get-WMIObject -Class Win32_BIOS -ComputerName $_ } | 
Select PSComputerName, Version, Manufacturer | 
ConvertTo-Html | 
Out-File C:\test4.html
于 2013-07-16T14:51:39.873 回答