Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Powershell Output Format

$
0
0

Hi everyone,

is my first time posting in this group, I hope you can help me because I'm getting crazy with formating in PowerShell.

I have a small scripts which shows by screen the total size of server hard disks and the uptime for each one.

How can I have in "Estadísticas de almacenamiento" all the 3 servers one below the other? Instead of to have 3 different headlines:

My code is the following:

$harddisk1=get-WmiObject win32_logicaldisk -Computername server_1 -filter "DriveType=3" |  Select-Object @{Name="Server Name";Expression={"{0}" -f($server1[1])}},  DeviceID, @{Name="Size (GB)";Expression={"{0:N2}" -f($_.size/1GB)}}, @{Name="FreeSpace (GB)";Expression={"{0:N2}" -f($_.freespace/1gb) }}, @{Name="% Free";Expression={"{0:N2}" -f(($_.freespace/$_.size)*100)}} | Format-Table
$harddisk2=get-WmiObject win32_logicaldisk -Computername server_2 -filter "DriveType=3" |  Select-Object @{Name="Server Name";Expression={"{0}" -f($server2[1])}}, DeviceID, @{Name="Size (GB)";Expression={"{0:N2}" -f($_.size/1GB)}}, @{Name="FreeSpace (GB)";Expression={"{0:N2}" -f($_.freespace/1gb) }}, @{Name="% Free";Expression={"{0:N2}" -f(($_.freespace/$_.size)*100)}}| Format-Table
$harddisk3=get-WmiObject win32_logicaldisk -Computername server_3 -filter "DriveType=3" |  Select-Object @{Name="Server Name";Expression={"{0}" -f($server3[1])}}, DeviceID, @{Name="Size (GB)";Expression={"{0:N2}" -f($_.size/1GB)}}, @{Name="FreeSpace (GB)";Expression={"{0:N2}" -f($_.freespace/1gb) }}, @{Name="% Free";Expression={"{0:N2}" -f(($_.freespace/$_.size)*100)}}| Format-Table

And the last question, is How can I get this information in a HTML table?

I've seen many tutorials about formating the output but only know format a unique cmdlet.

Thanks a lot for your help

Best Regards,


Tecnico Superior de Sistemas


Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>