I'm facing an issue of getting all vms configuration ( using Get-ScVirtualMachine command) into an array from an input file.
The code is this one below
$VmsList = Get-Content C:\VmsList.txt
foreach($vm in $VmsList){
$Result += Get-SCVirtualMachine -Name $vm
}
And I have this error
Method invocation failed because [Microsoft.SystemCenter.VirtualMachineManager.VM] does not contain a method named 'op_Addition'.
At line:3 char:1
+ CategoryInfo: InvalidOperation: (op_Addition:String) [], RuntimeException + FullyQualifiedErrorId: MethodNotFound
Method invocation failed because [Microsoft.SystemCenter.VirtualMachineManager.VM] does not contain a method named 'op_Addition'. At line:3 char:1
+ CategoryInfo: InvalidOperation: (op_Addition:String) [], RuntimeException + FullyQualifiedErrorId: MethodNotFound
Get-SCVirtualMachine: Cannot validate argument on parameter 'Name'. The character length (0) of the argument is too short. Specify an argument with a length that is greater than or equal to "1", and then try the command again. At line:3 char:39
~~~
I forgot to declare the array $result = @()
I resolved the issue.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.