Hello,
We have a problem with vSphere PowerCLI 5.1 Release 1 build 793510.
We have a user - "test_user" in our vCenter Server to which we provide administrative permissions only on resource pool - "TestResourcePool".
We have a VM - "test-vm" under this resource pool.
Now we need to execute some simple commands from PowerCLI under "test_user".
We successfully connecting to vCenter server by "Connect-VIServer".
We successfully receive a list of VMs of "TestResourcePool" by "Get-VM".
But if we try to reconfigure VM, for example "Set-VM test-vm -NumCPU 1", we receive error: Set-VM "Index was outside the bounds of the array" At line:1 char:7 - FullyQualifiedErrorId : Core_BaseCmdlet_UnknownError,VMware.VimAutomation.ViCore.Cmdlets.Commands.SetVM.
While we can successfully reconfigure VM from Windows vSphere Client.
We found that if we provide any empty permission (create new role in vCenter and uncheck all privileges) for "test_user" on ESXi host level, then reconfiguring VM from PowerCLI completes successfully.
But we need that user has no permissions on ESXi host level and cannot see any information about host from Windows vSphere Client.
And if we execute "Set-VM test-vm -NumCPU 1" under user which have administrative permissions on whole vCenter Server, not only on certain resource pool, command completes successfully.
How can we resolve this issue?
Do a Get-VIPermission and Get-VIRole return the correct info for those folders and that role ?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Here is output of Get-VIPermission and Get-VIRole.
Try running a Get-ErrorReport and perhaps the PowerCLI Dev Team can see what is going wrong from that.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Here is screenshot with the error.
Fyi, I was able to reproduce your problem on vSphere 5.1.
Works from the vSphere client, but not from PowerCLI.
That looks indeed like a bug.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Can we expect a fix in the next release?
I din't work for VMware, so no clue.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi there,
Can you share some more details about your environment ?
Which VC version do you use?
Is the resource pool inside cluster?
If there is a cluster:
Is it HA and/or DRS enabled?
And the last thing - could you copy and paste here the full error information, something like this:
PS> Set-VM ......
< error output is here>
PS> $lastError = $error[0]
PS> $lastError | select *
<this output will be useful for us, please paste it here>
Thanks,
Vitali
PowerCLI Team
Hello,
Which VC version do you use?
VC Version - VMware vCenter Server Version 5.0.0
Is the resource pool inside cluster?
Yes
If there is a cluster:
Is it HA and/or DRS enabled?
Yes, HA and DRS is enbaled. HA Admission Control Policy is set to percentage of cluster resources. DRS is set to fully automated.
And the last thing - could you copy and paste here the full error information, something like this:
PS> Set-VM ......
< error output is here>
PS> $lastError = $error[0]
PS> $lastError | select *
<this output will be useful for us, please paste it here>
PowerCLI C:\Windows\system32> Set-VM test-vm -NumCPU 1
Confirmation
Proceed to configure the following parameters of the virtual machine with name 'test-vm'?
New NumCpu: 1
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help
(default is "Y"):Y
Set-VM : 02.10.2012 11:49:09 Set-VM Index was outside the bounds of the array.
At line:1 char:7
+ Set-VM <<<< test-vm -NumCPU 1
+ CategoryInfo : NotSpecified: (:) [Set-VM], VimException
+ FullyQualifiedErrorId : Core_BaseCmdlet_UnknownError,VMware.VimAutomation.ViCore.Cmdlets.Commands.SetVM
PowerCLI C:\Windows\system32> $lastError = $error[0]
PowerCLI C:\Windows\system32> $lastError | select *
PSMessageDetails :
Exception : VMware.VimAutomation.Sdk.Types.V1.ErrorHandling.VimException.VimException: 02.10.2012 11:49:09 Set-VM Index was out side the bounds of the array. ---> System.IndexOutOfRangeException: Index was outside the bounds of the array.
at VMware.VimAutomation.ViCore.Impl.V1.Service.QueryServiceImpl.GetHostEnvironmentBrowser(ManagedObjectReference hostMoref)
at VMware.VimAutomation.ViCore.Impl.V1.Service.ComputeResourceServiceImpl.TryGetHostEnvironmentBrowser(String hostId)
at VMware.VimAutomation.ViCore.Impl.V1.Service.ComputeResourceServiceImpl.TryGetViNetHostConfigTarget(String hostId)
at VMware.VimAutomation.ViCore.Impl.V1.Service.VmServiceImpl.UpdateVM(VirtualMachineImpl vm, String name, String description, Nullable`1 memorySize, Nullable`1 cpuCount, String guestId, String alternateGuestName, OSCustomizationSpecImpl customization, Boolean allowNested, Boolean isRequestedAsync, Nullable`1 haRestartPriority, Nullable`1 haIsolationResponse, Nullable`1 drsAutomationLevel, Boolean toTemplate, Nullable`1 vmSwapfilePolicy, Nullable`1 version)
at VMware.VimAutomation.ViCore.Impl.V1.Service.VmServiceImpl.UpdateVM(VirtualMachineInterop vm, String name, String description, Nullable`1 memorySize, Nullable`1 cpuCount, String guestId, String alternateGuestName, OSCustomizationSpecInterop customization, Boolean allowNested, Boolean isRequestedAsync, Nullable`1 haRestartPriority, Nullable`1 haIsolationResponse, Nullable`1 drsAutomationLevel, Boolean toTemplate, Nullable`1 vmSwapfilePolicy, Nullable`1 version)
at VMware.VimAutomation.ViCore.Cmdlets.Commands.SetVM.DoWork(VIAutomation client, List`1 moList)
--- End of inner exception stack trace ---
TargetObject :
CategoryInfo : NotSpecified: (:) [Set-VM], VimException
FullyQualifiedErrorId : Core_BaseCmdlet_UnknownError,VMware.VimAutomation.ViCore.Cmdlets.Commands.SetVM
ErrorDetails :
InvocationInfo : System.Management.Automation.InvocationInfo
PipelineIterationInfo : {0, 1}
Hi again,
I've filed a bug for this issue and we will research it.
There's another problem - I still cannot reproduce it. Can you tell me some more details about your setup?
What permissions does testUser have on the following objects:
- the datastore where the VM resides
- the virtual port group to which the VM is connected
What is the type of the datastore - shared datastore or host local datastore?
Is the VM attached to distributed virtual switch or it is connected to standard switch?
What is the output of Get-VMHost cmdlet? Do you see the host to which the vm is currently attached to?
Thanks again,
Vitali
PowerCLI Team
Hello,
I've filed a bug for this issue and we will research it.
There's another problem - I still cannot reproduce it. Can you tell me some more details about your setup?
If your account have any permissions on ESXi host level, then you cant reproduce this error, your account must have permissions only on resource pool level.
What permissions does testUser have on the following objects:
- the datastore where the VM resides
Administrator + Propagate
- the virtual port group to which the VM is connected
Administrator + Propagate
What is the type of the datastore - shared datastore or host local datastore?
Shared datastore (FC connected to SAN with access to LUN on disk array).
Is the VM attached to distributed virtual switch or it is connected to standard switch?
Distributed virtual switch
What is the output of Get-VMHost cmdlet? Do you see the host to which the vm is currently attached to?
Get-VMHost returns nothing, command executes but no output
PowerCLI C:\Windows\system32> Get-VMHost
PowerCLI C:\Windows\system32>
Hello,
The problem was fixed. Unfortunately we didn't have enough resources to fix it on time for 5.1 R2 (which will be released soon), but the fix will be available in the next release.
Hi,
I think my issue the same as TS issue, but error message is a little different.
PowerCLI C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\automation> Get-VM -Name "g11n-clnt-frn"
Name PowerState Num CPUs MemoryGB
---- ---------- -------- --------
g11n-clnt-frn PoweredOff 1 3.000
PowerCLI C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\automation> set-vm "g11n-clnt-frn" -MemoryGB 2
Confirmation
Proceed to configure the following parameters of the virtual machine with name 'g11n-clnt-frn'?
New MemoryMB: 2048MB
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"):
set-vm : 4/9/2013 2:56:22 PM Set-VM Cannot find the environment browser for VMHost with Id:
'HostSystem-host-1324'.
At line:1 char:1
+ set-vm "g11n-clnt-frn" -MemoryGB 2
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ResourceUnavailable: (HostSystem-host-1324:String) [Set-VM], ViError
+ FullyQualifiedErrorId : Client20_VmHostServiceImpl_TryGetHostEnvironmentBrowser_EnvironmentBrowserNotFound,VMwar
e.VimAutomation.ViCore.Cmdlets.Commands.SetVM
PowerCLI C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\automation> $lastError = $error[0]
PowerCLI C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\automation> $lastError | select *
writeErrorStream : True
PSMessageDetails :
Exception : VMware.VimAutomation.Sdk.Types.V1.ErrorHandling.VimException.ViError: 4/9/2013 2:56:22 PM
Set-VM Cannot find the environment browser for VMHost with Id: 'HostSystem-host-1324'.
at VMware.VimAutomation.ViCore.Impl.V1.Service.ComputeResourceServiceImpl.TryGetHostEnvironm
entBrowser(String hostId)
at VMware.VimAutomation.ViCore.Impl.V1.Service.ComputeResourceServiceImpl.TryGetViNetHostCon
figTarget(String hostId)
at VMware.VimAutomation.ViCore.Impl.V1.Service.VmServiceImpl.UpdateVM(VirtualMachineImpl
vm, String name, String description, Nullable`1 memorySize, Nullable`1 cpuCount, String
guestId, String alternateGuestName, OSCustomizationSpecImpl customization, Boolean
allowNested, Boolean isRequestedAsync, Nullable`1 haRestartPriority, Nullable`1
haIsolationResponse, Nullable`1 drsAutomationLevel, Boolean toTemplate, Nullable`1
vmSwapfilePolicy, Nullable`1 version)
at VMware.VimAutomation.ViCore.Impl.V1.Service.VmServiceImpl.UpdateVM(VirtualMachineInterop
vm, String name, String description, Nullable`1 memorySize, Nullable`1 cpuCount, String
guestId, String alternateGuestName, OSCustomizationSpecInterop customization, Boolean
allowNested, Boolean isRequestedAsync, Nullable`1 haRestartPriority, Nullable`1
haIsolationResponse, Nullable`1 drsAutomationLevel, Boolean toTemplate, Nullable`1
vmSwapfilePolicy, Nullable`1 version)
at VMware.VimAutomation.ViCore.Cmdlets.Commands.SetVM.DoWork(VIAutomation client, List`1
moList)
TargetObject : HostSystem-host-1324
CategoryInfo : ResourceUnavailable: (HostSystem-host-1324:String) [Set-VM], ViError
FullyQualifiedErrorId : Client20_VmHostServiceImpl_TryGetHostEnvironmentBrowser_EnvironmentBrowserNotFound,VMware.VimAu
tomation.ViCore.Cmdlets.Commands.SetVM
ErrorDetails :
InvocationInfo : System.Management.Automation.InvocationInfo
ScriptStackTrace : at <ScriptBlock>, <No file>: line 1
PipelineIterationInfo : {0, 1}
Is there a solution for this problem?
Like knikolov said, the Dev Team has a solution, but that solution didn't make it into PowerCLI 5.2 R2
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi koder2,
It seems to be the same problem. Error message seems to vary between different versions of vSphere. The fix will be available in the next version of PowerCLI. Currently a workaround is to give the user at least readonly access to the host the VM resides on. If you cannot do that there is another workaround - use Onyx and reuse the script that vSphere Client uses to update the memory size. This requires a little bit deeper knowledge of PowerCLI, but I hope you know what I'm talking about.
Kamen
PowerCLI team