Difference between ISE Tabs

Are there any good resources on what exactly the differences are between different Powershell tabs in ISE? For example, I can load a module in one and the other tabs can use it - yet variables (including globals) appear to be separate and distinct between different tabs.

I ask because I am using a Connection cmdlet (VMware PowerCLI’s Connect-VIServer) that appears to set a global variable ($global:DefaultVIServer). But after connecting in one tab, then connecting in another tab, the first tab suddenly “breaks” with an error:

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.

While I don’t necessarily expect anyone here to know about this specific cmdlet, I am looking for insight into how the different tabs in ISE interact - what they share, what they don’t, etc. And any guidance toward a clue on what this cmdlet might be doing that causes this break and how I can work around this issue - even if this means greater isolation between the tabs.

Any help would be appreciated.

As far as I know, there is nothing shared across PowerShell tabs in the ISE. They’re completely separate runspaces. I’ve just done a little bit of testing on this, and neither modules nor variables were accessible across tabs. Not sure what’s causing the problem with those VMware commands.

I stand corrected on the module sharing. I would have sworn a cmdlet failed on me, I imported the module and it began working in both tabs. But I can no longer reproduce it, so I must have been suffering from too many sessions open :slight_smile:

With regard to the original issue, I’m beginning to suspect that the VMware stuff is caching connections somewhere outside of the PS runspace. Trying to figure it out.

Thank you Dave.

Dave, this conversation is interesting to me because in my testing variable values and functions are shared between the various tabs in the Windows Powershell ISE. I thought it was because the ISE was one environment no mater how many tabs are open. That is also why variable values survive between runs of the code.

It’s worth noting that this is the PoSh 4.0 ISE

My simple test on this:

Tab 1:

$ISEtest = "ABCXYZ"
"Variable value in tab1: $ISEtest"

Function Write-Test {
    "Function from Tab 1"

Results of running Tab 1

Variable value in tab1: ABCXYZ


"Variable value in tab 2: $ISEtest"


Results of running Tab 2 after running Tab 1

Variable value in tab 2: ABCXYZ
Function from Tab 1

We may be referring to different tabs. There are the “tabs” displayed when you have multiple files open in the ISE, but you’re still in a single runspace. Then there are the “PowerShell Tabs”. You can open an additional PowerShell Tab with Control+T, or from the File menu. Each PowerShell tab is isolated from the others.

Wow, how did I miss that? Excellent.

It seems that ISE tabs DO appear to share something between the tabs - a common PSDrive runspace.
Edit2: They appear to share SOMETHING about PSDrives, but I cannot confirm what. The VMware module appears to error creating a new PSDrive (“The specified mount name ‘vis’ is already in use.”). However, I can create a new PSDrive using the same name and root in different ISE tabs - which certainly gives the appearance of having different PSDrives for each tab/runspace.

Maybe the VMware module is doing something more low-level than PSDrives…?

----------------- [Leaving my previous (mostly inaccurate) comments for completeness]

[Edit: Well, let me rephrase. The creation of a PSDrive in one tab appears to block the creation of a PSDrive of the same name in another tab, even though the second tab doesn’t list that PSDrive as existing. Not terribly familiar with PSDrives, so not sure how this behavior exactly works.]

That appears to be what is happening with my issue. The Connect-VIServer appears to use both a global variable as well as a PSDrive mountpoint to track connection information (whether that is a good decision or not is a different question).

So can someone confirm for me that behavior and if so, why? Why create completely separate runspaces for functions, modules, variables, etc, but use the same runspace for PSDrives? Is that a bug with ISE or intended operation?

Interestingly, PS Consoles appear to use different PSDrive runspaces for each console window.

Just to follow up: I filed this as a bug with VMware who stated that their environment was designed to run in individual App Domains. While each Powershell console is a separate App Domain, ISE creates different PowerShell runspaces in each tab, but all within a single App Domain. So the connections are not aware of each other (different runspaces) but still collide (same App Domain).

They said they would attempt to redesign to account for same App Domain in a future release.