Hello folks,
To begin with I'm a newbie in powershell :)
What I'm trying to accomplish here is to retrieve properties from two wmi classes in a foreach loop. The classes are: win32_logicaldisk & win32_diskdrive.
In short, I want to combine info for hard drives from both classes.
My 'code' so far is the below which retrieves properties on from one variable.
My question is how a variable ($hdd) can retrieve members from more than one variable ($hwinfo, @logicalinfo) in the foreach loop so to be able to pass them in the $results variable.
$hwinfo = gwmi -Class win32_diskdrive -ComputerName localhost
$logicalinfo = gwmi -Class win32_logicaldisk -ComputerName localhost
foreach ($hdd in $logicalinfo) {
$result= @{ 'Drive Letter' = $hdd.Name;
'FileSystem' = $hdd.FileSystem;
'Size' = $hdd.Size /1GB -as [int];
'Disk Serial Number' = $hdd.VolumeSerialNumber;
'Computer Name'= $hdd.SystemName;
}
}
$newobjoutput = New-Object -TypeName psobject -Property $result
$newobjoutput