I have a small script which lists some parameters of VM however when the number of VM is more than 1 it gives error as below Method invocation failed because [System.Management.Automation.PSO...
See more...
I have a small script which lists some parameters of VM however when the number of VM is more than 1 it gives error as below Method invocation failed because [System.Management.Automation.PSObject] does not contain a method named 'op_Addition'. At :72 char:25 + $VMinfo +=$VM_Info + ~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (op_Addition:String) [], RuntimeException + FullyQualifiedErrorId : MethodNotFound Below is the scrip $VM_folder=Get-Folder -Name "*$VMname*" -Server $VCname |Get-VM function get-vminfo($VM_folder){ foreach ($VM in $VM_folder |Where-Object {$_.Guest.OSFullName -ne $null}) { $VM_Info=""|Select-Object VMName,Consolidation_Needed,Tools_Status,MemoryGB $VM_Info.VMName=$VM.ExtensionData.Summary.Config.Name $VM_Info.Consolidation_Needed=$VM.ExtensionData.Summary.Runtime.ConsolidationNeeded $VM_Info.Tools_Status=$VM.ExtensionData.Guest.ToolsStatus $VM_Info.MemoryGB=$VM.MemoryGB $VMinfo +=$VM_Info $VM_Info |ft } }