LucD,
Why am I not surprised you chimed in? :smileyhappy:
Does the '-NotDefault' option for Connect-VIServer not provide for isolation of connections? Well at the very least it will expose PowerCLI calls that maybe using default connections when you don't want that to happen, when I set the '-NotDefault' option, I found a few places in my scripting that were leveraging the default connections, where I had not intended that to happen. Since I fixed those issues, and still use the '-NotDefault' option, I seem to have eliminated the "you have modified..." issue. However, I have another issue, I am not sure how to solve now.
Scenario I...
Scheduled Task:
Script A (Parent Script)
User 1 Context (Service Account), not an interactive session
User 1, Script A connects to vCenter
User 1, Script B is invoked by Script A, via a queued, separate (powershell) run-space, connects to vCenter
User 1, Script B does work
User 1, Script B closes vCenter connection
Scenario I Result...
User 1, Script A connection to vCenter lost!
Scenario II...
User 1, Script B runs ad-hoc from interactive environment
User 1, Script B closes vCenter connection
Scenario II Result...
User 1, Script A connection to vCenter lost!
Required Result For Scenario I and II...
User 1, Script B can open and close connections to vCenter at any time, User 1, Script A, never loses its connection to vCenter, regardless of what Script B does, in reference vCenter connections. Expectation was that separate (powershell) run-space provided session isolation, which it does for powershell but not for PowerCLI apparently. I never want to pass a connection to Script B, I want Script B to have a completely separate connection to vCenter from Script A.
Will what you outlined address my need? That Script B explicit open/close of connections to vCenter cannot impact Script A? I think understand what you noted, but not how to implement it, and not entirely sure it will do what I need? I can't seem to find the Session id value? How can I get the session id in the first place? Moreover, I don't think that is what I want to have implemented, what you suggest is that Script A hands off its connection to Script B as a separate session, not a completely separate connection? Could I may the session id idea work, I think sure, if I have to... But I prefer isolated connections as outlined above if possible.
A temporary fix is to never have Script B close its vCenter connection if Script B is invoked by Script A, but that seems sloppy. Since Script B can be run at anytime... by User 1 interactively... even while Script A is alive as a scheduled task.
Thoughts?