Hello,
I have this script where I get the disk information and convert it to HTML.
When I do not copnvert this to HTML , I get the correct values on screen.
Only when I convert this to HTML it shows me the labels and the diskspace in a full number.
The Disk % is not shown in the HTML report.
My skills are not grown up enough to fix this or figure this out at the moment, I appreciate any help.
#The command below will get the details of Disk, convert the result to HTML code as table and store it to a variable
$DiscInfo = Get-CimInstance -Class win32_LogicalDisk -ComputerName $Computername | Select-Object @{Name="Size(GB)";Expression={$_.size/1gb}},`
@{Name="Free Space(GB)";Expression={$_.freespace/1gb}}, @{Name="Free_(%)";Expression={"{0,6:P0}" -f(($_.freespace/1gb)`
/ ($_.size/1gb))}}, DeviceID, DriveType, SystemName,VolumeName,freespace| Where-Object DriveType -EQ '3' |
ConvertTo-Html -As table -Property DeviceID,VolumeName,FreeSpace,Free_% -PreContent "<h2>Disk Information</h2>" -Fragment
ConvertTo-HTML -Body "$ComputerName $DiscInfo"`
-Head $header -Title "Computer Information Report" -PostContent "<p id='CreationDate'>Engineer : $Engineer , Creation Date: $(Get-Date)</p>"|
Out-File .\Report\AIS-Disc.html
The picture shows the output.
Because it is a part of a larger script it has a -fragment and a separate ConvertTo-html .
This is to make sure it is the same behavior as in the full script.
thank you for any help.