tag:blogger.com,1999:blog-2269516327950490847.post4414002848823673062..comments2023-03-28T08:39:06.775-04:00Comments on vNugglets: Show Currently Connected vCenter Servers in PowerCLI 5.0.1AC (@allen_crawford)http://www.blogger.com/profile/05360032132878174436noreply@blogger.comBlogger3125tag:blogger.com,1999:blog-2269516327950490847.post-45644250442024095412014-02-26T11:05:46.301-05:002014-02-26T11:05:46.301-05:00Checking to see if you are connected to any ViServ...Checking to see if you are connected to any ViServers:<br /><br />I have found the checking the value of $global:DefaultViServers is not an effective way to check if you are connected to a Server. If my computer loses it's network connection or if I try to use a previous active Powershell Console after hibernating my computer, the Value stored in $global:DefaultViServers remains intact. However if I issue a command, Powershell will respond that I am not connected. There may be better ways to check to see if you are really connected, but here is one I use:<br /><br />Get-VMHost -ErrorAction SilentlyContinue | Out-Null #Tries to list connected Host, suppresses any errors if not connected, suppress actual results if connected<br />if($? -eq "False") {Put your Code Here} # Checks Value of $? (True if completes successfully, False if Previous Command Fails)<br /><br />James Borris<br />jdborris@hotmail.com<br />Anonymoushttps://www.blogger.com/profile/07287852784069389131noreply@blogger.comtag:blogger.com,1999:blog-2269516327950490847.post-54573271468320621152013-02-18T19:45:01.409-05:002013-02-18T19:45:01.409-05:00I got this error message afterward ?
Get-VMHost :...I got this error message afterward ?<br /><br />Get-VMHost : You have modified the global:DefaultVIServer and global:DefaultVIServers system variables. This is not allowed. Please reset them to $null and reconnect to the vSphere server.<br />At C:\Users\Admin\AppData\Local\Temp\26ebc1c7-2527-4ab7-88cc-29c86e2e250b.ps1:1 char:11<br />+ Get-VMHost <<<< <br /> + CategoryInfo : NotSpecified: (:) [Get-VMHost], InvalidState<br /> + FullyQualifiedErrorId : VMware.VimAutomation.ViCore.Types.V1.ErrorHandling.InvalidState,VMware.VimAutomation.ViCore.Cmdlets.Commands.GetVMHost<br />Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-2269516327950490847.post-44407589948785403032012-04-26T13:43:46.108-04:002012-04-26T13:43:46.108-04:00Great function! Sure beats checking $global:Defau...Great function! Sure beats checking $global:DefaultVIServer all the time.Jaronhttps://www.blogger.com/profile/07052253326392713871noreply@blogger.com