Im writing a big script that scans WMI info from computers in AD. I have functions for diskinfo, raminfo and videocardinfo where disk and videocard have similar output styles. Problem is that depending on the order which the script runs them either ones output is blank. Here is the two functions:
function Get-DiskInfo {
$disk = Get-WMIObject Win32_Logicaldisk -ComputerName $computer |
Select @{Name="Computer";Expression={$computer}}, DeviceID,
@{Name="SizeGB";Expression={$_.Size/1GB -as [int]}},
@{Name="FreeGB";Expression={[math]::Round($_.Freespace/1GB,2)}}
Write-Host $Computer
$disk
}
and:
function Get-VRamInfo {
$vram = Get-WmiObject win32_videocontroller -ComputerName $computer |
Select @{Name="Computer";Expression={$computer}},
@{Name="VideoRAM";Expression={$_.adapterram / 1MB}},
Name
Write-Host $computer
$vram
}
One will get the output intended but the one that is run later in the script will output only computer names but no info
here is the full script: https://gist.github.com/ErkkaKorpi/f1b10a62ac79763fa38082b6c25e8f1b
What could be the problem?