OK here are my findings:
When I ran the script in my prodcution environment I got the following error:
Get-View : Cannot validate argument on parameter 'VIObject'. The argument is nu
ll or empty. Supply an argument that is not null or empty and then try the comm
and again.
At D:\VPO\test\test.ps1:32 char:19
+ $dts = get-view <<<< $_.ConfigManager.DateTimeSystem
+ CategoryInfo : InvalidData: (:) [Get-View], ParameterBindingVal
idationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,VMware.VimAutom
ation.ViCore.Cmdlets.Commands.DotNetInterop.GetVIView
When I ran the script in my test environment of 2 hosts I got this error:
esx02.flotech.lab.org
Exception calling "QueryDateTime" with "0" argument(s): "Unable to communicate
with the remote host, since it is disconnected."
At E:\Scripts\Test\test.ps1:35 char:27
+ $t = $dts.QueryDateTime <<<< ()
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodException
The operation '[$null] - [System.DateTime]' is not defined.
At E:\Scripts\Test\test.ps1:38 char:15
+ $s = ( $t - <<<< [DateTime]::UtcNow).TotalSeconds
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : NotAdefinedOperationForTypeType
Time on esx02.flotech.lab.org is within allowed range
esx01.flotech.lab.org
Time on esx01.flotech.lab.org is within allowed range
The common factor in both tests are that the hosts in both environments were disconnected.