Hello Luc, I am trying to run your code and being a complete noob in the powershell game I am getting the following error. Can you help.
Error is Unexpected token 'vms' in expression or statement
Unexpected token 'vms' in expression or statement.
At C:\Program Files\VMware\Infrastructure\VIToolkitForWindows\Scripts\disksize.
ps1:1 char:19
+ $report = @() $vms <<<< = Get-VM foreach ($vm in $vms){ foreach($hd in $vm |
Get-HardDisk){ $row = "" | select VMname, VMdisksize, server, respool $row.VMn
ame = $vm.Name $row.VMdisksize = $hd.CapacityKB $row.server = ($vm | Get-VMHost
).Name $rpImpl = $vm | Get-ResourcePool $rp = Get-View -id ($vm | Get-ResourceP
ool).Id $nested = "" while($rp.gettype().Name -eq "ResourcePool" -and $rp.Name
-ne "Resources"){ $nested = "/" + $rp.Name + "/" + $nested $rp = Get-View $rp.P
arent } $row.respool = $nested.TrimEnd("/") $report += $row } } $report | Expor
t-Csv "C:\test.csv" -noTypeInformation
I copy and pasted your code directly into powershell cmd window and also created a ps1 file. Same error on both. What am I doing wrong LOL.