Hi all,
I recently tried to amend my PowerShell disk space script, which previously outputted results to a text file, to instead create HTML reports. I want to make the report more presentable…
Original code
clear $file = get-Content 'X' # List of Computers $fileName = "X" + (Get-Date -Format dd.MM.yyyy) + ".TXT" foreach ( $node in $file) { get-WmiObject win32_logicaldisk -ComputerName $node | ft SystemName,DeviceID,@{Label="Total SIze";Expression={$_.Size / 1gb -as [int] }},@{Label="Free Size";Expression={$_.freespace / 1gb -as [int] }} -autosize | Out-File $filename -append -noclobber }
My amended code
clear $file = get-Content 'X' # List of Computers $fileName = "X" + (Get-Date -Format dd.MM.yyyy) + ".HTML" foreach ( $node in $file) { get-WmiObject win32_logicaldisk -ComputerName $node | ft SystemName,DeviceID,@{Label="Total SIze";Expression={$_.Size / 1gb -as [int] }},@{Label="Free Size";Expression={$_.freespace / 1gb -as [int] }} -autosize | ConvertTo-HTML | Out-File $filename -append -noclobber }
This runs fine, but there is an error in the outputted data.
https://static.spiceworks.com/shared/post/0020/0728/BGD8Lgp.png
Is anybody able to point me in the right direction?