VMware Communities > VMTN > VMware vSphere™ > Automation Tools > vSphere™ PowerCLI > Discussions

This Question is Possibly Answered

1 "correct" answer available (10 pts) 2 "helpful" answers available (6 pts)
1 Replies Last post: Mar 20, 2009 10:08 AM by c_shanklin
Reply

index out of range error with get-vmhostntpserver

Mar 18, 2009 7:51 PM

Click to view halr9000's profile Master halr9000 808 posts since
Jun 7, 2007
§ ATLLAPHROTTENBE {~} $a = Get-VMHost
§ ATLLAPHROTTENBE {~} $a[0] | Get-VMHostNtpServer
127.127.1.0
§ ATLLAPHROTTENBE {~} $a[1] | Get-VMHostNtpServer
Get-VMHostNtpServer : Index was outside the bounds of the array.
At line:1 char:28
+ $a[1] | Get-VMHostNtpServer <<<<
    + CategoryInfo          : NotSpecified: (:) [Get-VMHostNtpServer], IndexOutOfRangeExcep
   tion
    + FullyQualifiedErrorId : System.IndexOutOfRangeException,VMware.VimAutomation.Commands
   .Host.GetVMHostNtpServer


Add and Remove give similar errors on the same servers. I just checked server versions, looks like it's failing on my 3.0.2 servers, but works on my single 3.5 server. If this isn't supported, then you need a better error...






vExpert, PowerShell MVP, VI Toolkit forum moderator
Author of the upcoming book: Managing VMware Infrastructure with PowerShell
Co-Host, PowerScripting Podcast (http://powerscripting.net)
Need general, non-VMware-related PowerShell Help? Try the forums at PowerShellCommunity.org
Reply Re: index out of range error with get-vmhostntpserver Mar 20, 2009 10:08 AM
Click to view c_shanklin's profile Master c_shanklin 740 posts since
Dec 3, 2007
VMware
Right (not supported on 3.0.2) and right (better error)
Actions