Im writing a powershell script which prints disk information from computers from AD OU. My function looks like this:
function Get-DiskInfo {
$disk = Get-WMIObject Win32_Logicaldisk -ComputerName $computer |
Select DeviceID,
@{Name="SizeGB";Expression={$_.Size/1GB -as [int]}},
@{Name="FreeGB";Expression={[math]::Round($_.Freespace/1GB,2)}}
Write-Host $Computer "Disks: "$disk
if i would run that Get-WMIObject against a single computer i get the following output:
DeviceID SizeGB FreeGB
-------- ------ ------
C: 953 757,08
But if i run the function against multiple computers the printout looks like this:
Disks: @{DeviceID=C:; SizeGB=214; FreeGB=21,83} @{DeviceID=D:; SizeGB=932; FreeGB=740,09} @{DeviceID=E:; SizeGB=0; FreeGB=0}
Im farely new to powershell so is there something i should be doing differently to get the output look nicer
Whole script: https://gist.github.com/ErkkaKorpi/f1b10a62ac79763fa38082b6c25e8f1b