I want to create an overview of the local computer in Powershell and output it in JSON via a hash table. Now this can have several hard disks and it must be created dynamically in the hash table.
My Code:
$name = (Get-WmiObject -Class Win32_ComputerSystem -Property
Name).Name @{foreach ($Disk in $Disk) { $stats.Add("$platten", $Disk[0].VolumeName) }
stats = @{ $name= @{
CPUusage = $CPU
RAMusage = $ram
disknames = $disknames[1]
SSDsum = $ssdsum
HDDsum = $hddsum
Disksum = $disksum
}
$disk1 = @{
}
$disk2 = @{
}
$disk3 = @{
}
}}
Now I ask the hard drives and saves them in an Hash table. Then the foreach loop should go through each disk and enter the data into the other hash table.
And here comes the Error, i try to put it into the Hashtable and it did not works..