hi
why am I not getting anything on numcpu or mmeory gb
$
results = @()
$vms = get-content "c:\servers.txt"
foreach ($vm in $vms) {
$vmhardisk = get-vm $vm | get-harddisk
$result = ""| select vmname, numcpu, memorygb, harddiskname, harddiskcapacitygb
$result.vmname = $vm
$result.numcpu = $vm.numcpu
$result.memorygb = $vm.memorygb
$result.harddiskname = $vmharddisk.name
$result.harddisklcapacitygb = [system.math]::round($vmharddisk.capacitygb, 0)
$results += $result
}
Since you are populating it with Get-Content, it's a string.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
The $vm holds a string with name of the VM, not the object.
Change the line to
$vms = Get-VM -Name (Get-Content "c:\servers.txt")
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
hi luicd,
how can i tell if $vm is a string or object?
Try $vm.GetType().FullName
Since you are populating it with Get-Content, it's a string.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference