Cannot index into a null array.
At line:13 char:9
+ Set-Datastore -Datastore $datastore -name (Get-VMHost $ESXHos ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : NullArray
This was the error I encountered.