Tocano
Enthusiast
Enthusiast

VI Connections in Multiple Tabs in PowerShellISE possible?

I like to keep connections to my multiple vCenters in different console windows. I started renaming the console WindowTitle to address the challenge of keeping straight which console is connected to which server. This works, but consoles still lack the functionality and flexibility of the ISE (copy/paste, syntax highlighting, debugging commands, script variables accessible in console, etc). So I started using tabs within the ISE - each tab a different VI server - and I love how much easier and more efficient it is ... except. Every time I switch to a new tab/server, I have to reconnect. Because of the way that ISE manages global scope variables vs consoles, whenever I Connect-VIServer, the other tabs/servers lose their mind and will error with:

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.

I believe this has something to do with the difference in scoping between individual PS consoles vs the ISE - though I'm not exactly positive what/why. Global variables do not appear to actually be accessible across tabs, yet Connect-VIServer does appear to break something with regard to the global:DefaultVIServer(s) variables.

So is it even possible to have different connections in different ISE tabs or does the way PowerCLI uses the DefaultVIServers variables make that impossible?

Some things I've tried:

* Setting PowerCLI to run in Multiple Server mode

     - Set-PowerCLIConfiguration -DefaultVIServerMode Multiple -Scope AllUsers

* Setting ISE to run in Multi-thread Apartment mode

     - [launching] PowerShell_ISE.exe -mta

Neither appear to work. Any help would be appreciated.