I recently noticed some very odd behavior with the $global:defaultVIServer(s) variables.
The content was changing in the middle of my script; in particular $global:defaultVIServer.Name changed from
10.10.10.10 to 10.10.10.10@443
For some reason a port number was getting pasted to the end of the name field, which failed in the Test-Connection (ping) cmdlet.
After some digging, I tracked it down to my use of the VMware global variable, vmstores
The line, below overwrites $global:defaultVIServer
$dsList = (dir -path vmstores:)
Code snippet
connect-VIServer $vctIP
$global:defaultVIServer | fl
$dsList = (dir -path vmstores: )
$global:defaultVIServer | fl
$dsList | fl
You can see that $global:defaultVIServer gets overwritten with the $dsList data after the dir command
Screen shots are attached.
Minimally, I have to disconnect from my servers and reconnect to fix this.
Is there a better way to get the list of datastores (and their paths) with PowerCLI 6.0?
Maureen