I have 7 VMs in a test environment;
WinXP-test-a
WinXP-test-b
WinXP-test-c
WinXP-test-d
WinXP-test-ws
nfs-test (ubuntu 64-bit)
vcs-test (vCenter, server 2003)
5 Windows XP 32-bit
1 Windows 2003 32-bit
1 Ubuntu linux 64-bit
Connected to the vCenter running on vcs-test, I can run:
Get-VMResourceConfiguration -VM ( Get-VM MyVM )
but it only works for the ubuntu vm and the windows 2003 vm. All the XP vms + any new XP vms i create, all come back with this error:
Get-VMResourceConfiguration -VM ( Get-VM WinXP-test-a )
Get-VMResourceConfiguration : Object reference not set to an instance of an object.
At line:1 char:28
+ Get-VMResourceConfiguration <<<< -VM ( Get-VM WinXP-test-a )
+ CategoryInfo : NotSpecified: ( ,
NullReferenceException
+ FullyQualifiedErrorId : System.NullReferenceException,VMware.VimAutomati
on.Commands.GetVMResourceConfiguration
I get the same error on the XP VMs if I try:
get-vm * | ForEach-Object {
$myconfig = ( get-vm $_) | get-vmresourceconfiguration
}
Any ideas?
Env details:
VMware vSphere PowerCLI 4.0 U1 build 208462
vMware vCenter Server 4.0.0 build-208111
Server Name : esxi.test.com
Name : VMware ESXi
Version : 4.0.0
Build : 208167
FullName : VMware ESXi 4.0.0 build-208167
ApiVersion : 4.0
Server Name : esx.test.com
Name : VMware ESX
Version : 4.0.0
Build : 208167
FullName : VMware ESX 4.0.0 build-208167
ApiVersion : 4.0
Interesting I get the same thing in my environment
VC: 20811
ESX: 4U1 219382
PCLI: 208462
Here is a another way to access some of the information, depending on what exactly you are after:
Get-VM -name xpsoe | get-view | Select @{N="Name"; E={$_.Name}}, @{N="MemoryMB"; E={$_.Config.Hardware.MemoryMB}} Name MemoryMB ---- -------- XPSOE 256
Other items:
.Config.Name .Config.Hardware.NumCPU .Config.Hardware.MemoryMB .Config.CpuAllocation.Reservation .Config.CpuAllocation.Limit .Config.CpuAllocation.Shares.Shares .Config.MemoryAllocation.Reservation .Config.MemoryAllocation.Limit .Config.MemoryAllocation.Shares.Shares
HTH in the mean time
Herschelle42
Thanks Herschelle
It's nice to know i'm not alone!
Thanks for the code, that should be a big help!
Hi,
Thanks for reporting this issue. I'm trying to reproduce the problem but with no success. I suspect that some specific data retried by the server breaks the cmdlet logic. So it'll be very useful if you provide the values for the VM that fails the cmdlet using this script:
$vm = Get-VM -name WinXP-test-a | get-view $resourceConfig = "" | select cpuAffinity, cpuReservation, cpuLimit, cpuSharesLevel, cpuSharesNum, memReservation, memLimit, memShares, memSharesNum, htSharing $resourceConfig.cpuAffinity = $vm.config.cpuAffinity $resourceConfig.cpuReservation = $vm.config.cpuAllocation.reservation $resourceConfig.cpuLimit = $vm.config.cpuAllocation.limit $resourceConfig.cpuSharesLevel = $vm.config.cpuAllocation.shares.level $resourceConfig.cpuSharesNum = $vm.config.cpuAllocation.shares.shares $resourceConfig.memReservation = $vm.config.memoryAllocation.reservation $resourceConfig.memLimit = $vm.config.memoryAllocation.limit $resourceConfig.memShares = $vm.config.memoryAllocation.shares.level $resourceConfig.memSharesNum = $vm.config.memoryAllocation.shares.shares $resourceConfig.htSharing = $vm.config.flags.htSharing echo $resourceConfig
Thanks,
Yasen
I have a few VMs that give the same error.
Your script returns
cpuAffinity : cpuReservation : 0 cpuLimit : -1 cpuSharesLevel : normal cpuSharesNum : 2000 memReservation : 0 memLimit : 512 memShares : normal memSharesNum : 2560 htSharing : any
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi Yasen
It returns:
cpuAffinity : cpuReservation : 0 cpuLimit : -1 cpuSharesLevel : normal cpuSharesNum : 1000 memReservation : 0 memLimit : -1 memShares : normal memSharesNum : 2560 htSharing : any
Thanks guys!
We'll continue to investigate this issue. Just one thing. Can you get the full exception details of the error
Get-VMResourceConfiguration -VM ( Get-VM WinXP-test-a ) -ErrorVariable err $err[0].Exception | select *
Regards,
Yasen
Hmm
that just returns:
[vSphere PowerCLI] C:\wintools\lib> Get-VMResourceConfiguration -VM ( Get-VM Win XP-test-a ) -ErrorVariable err $err[0].Exception | select * Cannot index into a null array. At line:1 char:85 + Get-VMResourceConfiguration -VM ( Get-VM WinXP-test-a ) -ErrorVariable err $err[ <<<< 0].Exception | select * + CategoryInfo : InvalidOperation: (0:Int32) [], RuntimeException + FullyQualifiedErrorId : NullArray
This is the complete $err content
ErrorRecord : Object reference not set to an instance of an object. StackTrace : at System.Management.Automation.Internal.PipelineProcessor.SynchronousExecuteEnumerate(Object input, Hashtable errorRe sults, Boolean enumerate) at System.Management.Automation.PipelineNode.Execute(Array input, Pipe outputPipe, ArrayList& resultList, ExecutionCon text context) at System.Management.Automation.StatementListNode.ExecuteStatement(ParseTreeNode statement, Array input, Pipe outputPi pe, ArrayList& resultList, ExecutionContext context) WasThrownFromThrowStatement : False Message : Object reference not set to an instance of an object. Data : {} InnerException : System.NullReferenceException: Object reference not set to an instance of an object. at VMware.VimAutomation.Client20.VmServiceImpl.GetVmDiskResourceConfiguration(String vmId) at VMware.VimAutomation.Client20.VmServiceImpl.GetVMResourceConfiguration(String vmId) at VMware.VimAutomation.Client20.VmServiceImpl.GetVMResourceConfiguration(VirtualMachine vm) at VMware.VimAutomation.Commands.GetVMResourceConfiguration.DoWork(VIAutomation client, List`1 refs) at VMware.VimAutomation.BaseCmdlet.DoWorkEx(VIAutomation client, List`1 moList) at VMware.VimAutomation.Util.ClientVisitor`1.Visit(T[] objs, Worker worker, ErrorCallback errorCallback) at VMware.VimAutomation.BaseCmdlet.ProcessRecordCore() at VMware.VimAutomation.BaseCmdlet.ProcessRecord() at System.Management.Automation.Cmdlet.DoProcessRecord() at System.Management.Automation.CommandProcessor.ProcessRecord() TargetSite : System.Array SynchronousExecuteEnumerate(System.Object, System.Collections.Hashtable, Boolean) HelpLink : Source : System.Management.Automation
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
The error is finally reproducible and it's fixed for the next release. It turns out that some VM HDDs (I've tested with IDE hdds) does not have default shares and this cause the error.
Thanks again for the feedback and help to fix this issue.
Regards,
Yasen