I have a script that I run against a vCenter server. Basically finds all vm's in vCenter and ruins a get-wmiobject command against them to get the VMNAME, Partition, Offset and Status and exports it to excel.
Here's a sample output of the data that gets exported to excel:
VMName | Partition | Offset | Status |
pdxvvmdb1 | Disk #0, Partition #1 | 8193150KB | Partition NOT aligned |
pdxvvmdb1 | Disk #0, Partition #1 | 8193150KB | Partition NOT aligned |
My "problem" is its not giving me the correct partition info in excel (via system info), see below.
It only has 1 vmdk with 2 partitions, so it should output both partition 1 and 2 and the offsets, since they're both incorrect?
Also looking to add a line to the script to add the datastore and the vmdk file location ([PDXESX1_RAID] pdxvvmdb1/pdxvvmdb1.vmdk) in this case and have that output to the excel. Possible?
I attached the script since its pretty long....
I thought so, but I've never had to do 2 calls in a powercli script... Ill play around with it and see if I can get it to work.
Can't you just do
$wmiOS = get-wmiobject -class "Win32_OperatingSystem" -namespace "root\CIMV2" -ComputerName $vm -ErrorAction silentlycontinue
$wmiPart = get-wmiobject -class "Win32_DiskPartition" -namespace "root\CIMV2" -ComputerName $vm -ErrorAction silentlycontinue foreach ($objItem in $wmiPart){ # Loop through the partitions
....
$wmiOS.Caption # Reference the OS class
....
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Of course I can
I had to change a couple things and remove the loop so it wouldnt output the contents in the powercli screen.
When I tried it on my own I had line below incorrect:
Correct:
foreach ($objItem in $wmiPart)
Incorrect:
foreach ($objItem in $wmiOS)
Amazing what I've learned. Thanks again!