VMware Cloud Community
halr9000
Commander
Commander

index out of range error with get-vmhostntpserver

§ 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|http://www.vmware.com/communities/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

My signature used to be pretty, but then the forum software broked it. vExpert. Microsoft MVP (Windows PowerShell). Author, Podcaster, Speaker. I'm @halr9000
0 Kudos
1 Reply
admin
Immortal
Immortal

Right (not supported on 3.0.2) and right (better error)

0 Kudos