Hi all,
I am trying to create VM using PowerCLI 5.0 as a non-administrator user.
The user has just enough permission at specific ResourcePool "R", Datastore "D" and Folder "F" to create a VM using VMWare Client, i.e.
In VMWare Client, user is able to select target folder, click create new VM, select resource pool and datastore, and successfully create a VM.
I would assume I should be able to perform the same action using PowerCLI under the same priviledge,
however this doesn't seem to be the case.
If I enter the following command:
New-VM -Name VM -ResourcePool R -Datastore D -Location F
The following exception is displayed and PowerCLI exits:
An error has occurred that was not properly handled. Additional information is shown below. The Windows PowerShell process will exit.
Unhandled Exception: System.NullReferenceException: Object reference not set toan instance of an object.
at VMware.VimAutomation.ViCore.Impl.V1.Service.DatastoreServiceImpl.GetDatacenterDatastoreList()
at VMware.VimAutomation.ViCore.Impl.V1.Service.StorageServiceImpl.<GetDatastoreStream>d__0.MoveNext()
at VMware.VimAutomation.Sdk.Util10.CommonUtil.CollectStreamToArray[T](IEnumerable`1 collection)
at VMware.VimAutomation.ViCore.Impl.V1.Service.StorageServiceImpl.GetDatastore(IList`1 objectList, IList`1 nameList, String[] idList, Boolean refresh)
at VMware.VimAutomation.ViCore.Impl.V1.Service.ViCoreObjectInteropCoreServiceProviderImpl.GetNonInventoryObjectList(VIAutomation client, Type interfaceType, Object contextEntity)
at VMware.VimAutomation.ViCore.Impl.V1.Service.ViCoreObjectInteropCoreServiceProviderImpl.GetObjectListFromServer(VIAutomation client, Type type, Object contextEntity)
at VMware.VimAutomation.ViCore.Impl.V1.Service.ViCoreObjectInteropCoreServiceProviderImpl.GetObjectsByName(VIAutomation client, IList`1 nameList, IList`1 interfaceTypeList, IList`1 contextList)
at VMware.VimAutomation.ViCore.Impl.V1.Service.ViCoreObjectInteropCoreServiceProviderImpl.<>c__DisplayClass5.<GetObn>b__0()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.runTryCode(Object userData)
at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
The stack trace hints me that something is wrong about getting datastore list,
trying to do a "Get-Datastore" would show the same error :
PowerCLI C:\Documents and Settings\Administrator> get-datastore
Get-Datastore : 12/26/2011 12:46:24 PM Get-Datastore Object reference not set to an instance of an object.
At line:1 char:13
+ get-datastore <<<<
PowerCLI C:\Documents and Settings\Administrator>
Next, I further confirmed that if I grant "Browser Datastore" priviledge to the user at Datacenter level, the error will be gone,
however, this is an unwanted workaround as we do not want user to be able to browse every datastore.
I would expect Get-Datastore to display a list with single item "R", or at least an empty list (like what you get from Get-VM, Get-VMHost etc when you do not have priviledge), instead of throwing exception.
Has anyone encountered similar issue, without any workaround?
Where can I officially submit this problem in a hope to have it fixed?
Thanks in advance.