I am reading computer names from a cvs file and getting system information and exporting the information to a HTML file. I am testing two computers (computer1 and computer2); however, I only get the output for computer2. How can I append the output to an HTML?. Here is the code.
$cvsFile = "C:\scripts\Get Macaddress remote computers\GetMacaddressERN\ComputerName .csv"$a = Import-Csv $cvsFile
Clear-Host
$filepath = (Get-ChildItem env:\userprofile).value
Add-Content "$Filepath\style.CSS" -Value " body {
font-family:Calibri;
font-size:10pt;
}
th {
background-color:black;
color:white;
}
td {
background-color:#19fff0;
color:black;
}"
Write-Host "CSS File Created Successfully... Executing Inventory Report!!! Please Wait !!!" -ForegroundColor Yellow
Foreach ( $computerSystem in $a ) {
$comp = Get-CimInstance CIM_ComputerSystem -ComputerName $computerSystem.Pcname
$computerBIOS = Get-CimInstance CIM_BIOSElement -ComputerName $computerSystem.Pcname
$computerOS = Get-CimInstance CIM_OperatingSystem -ComputerName $computerSystem.Pcname
$computerCPU = Get-CimInstance CIM_Processor -ComputerName $computerSystem.Pcname
$computerHDD = Get-CimInstance Win32_LogicalDisk -ComputerName $computerSystem.Pcname -Filter "DeviceID = 'C:'"
$macaddress = Get-CimInstance win32_networkadapterconfiguration -ComputerName $computerSystem.Pcname -filter "IpEnabled = True"| select -ExpandProperty macaddress
$manufacturer = $comp.Manufacturer
$computername = $comp.Name
$model = $comp.Model
$serialnumber = $computerBIOS.SerialNumber
$CPU = $computerCPU.Name
$OS = $computerOS.caption + ", Service Pack: " + $computerOS.ServicePackMajorVersion
ConvertTo-Html -Body "<font color = blue><H4><B>Report Executed On</B></H4></font>$ReportDate
<font color = blue><H4><B>Computer Name: </B></H4></font> $computername
<font color = blue><H4><B>Manufacturer: </B></H4></font> $manufacturer
<font color = blue><H4><B>Model: </B></H4></font>$model
<font color = blue><H4><B>Serial Number: </B></H4></font>$serialnumber
<font color = blue><H4><B>CPU: </B></H4></font>$CPU
<font color = blue><H4><B>Operating System: </B></H4></font>$OS
<font color = blue><H4><B>Mac Address</B></H4></font>$macaddress" -CssUri "$filepath\style.CSS" -Title "Server Inventory" | Out-File "$FilePath\$ComputerName.html"
}
Write-Host "Script Execution Completed" -ForegroundColor Yellow
Invoke-Item -Path "$FilePath\$ComputerName.html"