VMware Cloud Community
sfresher
Contributor
Contributor
Jump to solution

Is there anyway to shared a connection from different shell?

Let's say I first do a Connect-VIServer, then i can do a Get-VMHost.  However, if I open another powershell window, the previously connected VIServer no longer exists.  Is there anyway to overcome this?  I am working on a multi-process script and I really don't want to connect/disconnect every time.

Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

That is normal behaviour, if you start a new PS session, you have a new environment.

All the variables you have in a specific PS session, are unique to that session. They are not copied to a new session you start from within the first session.

You can start new sessions from within a PS session by executing the powershell.exe command or by executing the Start-Job cmdlet.

And you could use for example environment variables to pass information between the scripts.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

Reply
0 Kudos
4 Replies
Ramverma
Enthusiast
Enthusiast
Jump to solution

This seems to be issue with your login account. I tried  get-esx to esxi server with root account and I was able to access powershell multiple windows. Its also working fine with connect-VIserver command.

Reply
0 Kudos
sfresher
Contributor
Contributor
Jump to solution

I am also using root access to the esxi server, but I don't see a connection can be shared from different shell.  By the way, how do you launch the shell?  I am using the PowerCLI shortcut on the start menu.

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

That is normal behaviour, if you start a new PS session, you have a new environment.

All the variables you have in a specific PS session, are unique to that session. They are not copied to a new session you start from within the first session.

You can start new sessions from within a PS session by executing the powershell.exe command or by executing the Start-Job cmdlet.

And you could use for example environment variables to pass information between the scripts.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
sfresher
Contributor
Contributor
Jump to solution

Thanks for clarifying this!

Reply
0 Kudos