Link to home
Start Free TrialLog in
Avatar of AlLerner
AlLerner

asked on

How to find out, if a remote Session has allready been imported

When we import-pssession, Poweshell creates a temporary module for implicit remoting. When we remove-pssession, all the temporary modules that belong to it (Powershell creates a new module every time we Import the session!) are removed.

My goal is to know, if a certain PSSession has been already imported or not. The idea was to find out, if there are modules bound to this session. Unfortunately I could not find any properties in modules that would reference the session neither the session properties referencing the modules. But Powershell knows it somehow!

Does anyone have an idea?

Thanks
Alexander Lerner
Avatar of FOX
FOX
Flag of United States of America image

run the command Get-PSSession to see which sessions are connected to the local computer
run the command Get-PSSessionConfiguration to see the registered session configurations on the local computer
Avatar of AlLerner
AlLerner

ASKER

Unfortunately it does not solve the Problem. Please read the question again. Thank you.
The command Get-Module will show you all modules you have on your session
Thank you. On which session? I am still in my local session, but I have imported a remote-session and now I look for indices, that a certain remote session has already been imported.
using Get-PSSession will show you all sessions on your local machine.  Each session has an ID/guid number. from there you can use a
Connect-PSSession IDNumber

in your powershell run a get-help Get-PSSession -detailed  (for syntax)  
Also run get-help PSSession -detailed                               (for more commands)
Dear Foxluv... Please, read my question. I don't want to know the ID of the session. I don't want to connect to session because it has never been disconnected. I want to know, if the session has been imported!!!!!!
SOLUTION
Avatar of footech
footech
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Well, it is not exactly what I would like to use, because Microsoft can change the description of such module any time it likes, somewhere between the release 5 and 6. Mor than that, the description is in the language of OS, so it can be tricky to look, where exactly in is the URI (not actually the server name) of the session to look for. But there is likely nothin else one could actually use.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ID: 41769351 provides a method that will work for at least some circumstances.
ID: 41774352 provides a method that is more reliable.