Hello
I'm going crazy now
I'm trying to get some inventory from vm:s but I'm stuck at the harddisk result. I'm leaving some part out that works....
$vmname = Read-Host "Enter name of vm"
$vmresult = Get-VM $vmname
$vmsum = "" | Select Name,OS,NumCPU,CPUCorePerSocket,DiskName
$vmsum.Name = $vmresult.Name
$vmsum.OS = $vmresult.Extensiondata.Config.GuestFullName
$vmsum.NumCPU = $vmresult.Extensiondata.Config.Hardware.NumCPU
$vmsum.CPUCorePerSocket = $vmresult.Extensiondata.Config.Hardware.NumCoresPerSocket
ForEach ($vmgdisk in (get-vm $vmname | Get-Harddisk))
{
$vmsum.DiskName += $vmgdisk.Name
}
$vmsum
The result for this is like this:
Name | :servername |
OS | : Microsoft Windows Server 2012 (64-bit) |
NumCPU | : 2 |
CPUCorePerSocket : 2
DiskName | : Hard disk 1Hard disk 2 |
What i need is to have the second, third and fourth disk if there are any show up at an own row
Name | : servername |
OS | : Microsoft Windows Server 2012 (64-bit) |
NumCPU | : 2 |
CPUCorePerSocket : 2
DiskName | : Hard disk 1 |
DiskName | : Hard disk 2 |
Same goes for the type and size of disk, that they need to show up on different rows.
It's probably a minor thing, but i can't get it to work.
I would very greatful.