Quantcast
Channel: VMware Communities: Message List
Viewing all articles
Browse latest Browse all 232319

Calling Initialize-PowerCLIEnvironment.ps1 causes variable leak

$
0
0

Hi!

 

I've noticed that when I'm loading PowerCLI modules (as suggested in this blog) some of the variables in my script get rewritten. Here's a simplified example (I'm using PowerCLI 6.3R1):

$Configuration='Something valuable'

if ( !(Get-Module-NameVMware.VimAutomation.Core-ErrorActionSilentlyContinue) ) {

   .“C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\Scripts\Initialize-PowerCLIEnvironment.ps1”

$Configuration|fl*

 

Returns:

DefaultVIServerMode         : Multiple

ProxyPolicy                 : UseSystemProxy

ParticipateInCEIP           : True

CEIPDataTransferProxyPolicy : UseSystemProxy

DisplayDeprecationWarnings  : True

InvalidCertificateAction    : Unset

WebOperationTimeoutSeconds  : 300

VMConsoleWindowBrowser      :

Scope                       : Session

 

I was wondering if there is another way to do this or if there are any plans to introduce a module that could be loaded using Import-module instead of dot-sourcing to avoid variable leakage? That module could offer a slightly different experience that could suit better for embedding into other scripts (i.e. avoid things like, rewriting PSHost title, changing PS prompt, changing location, etc.)

 

Thanks!

 

 

 


Viewing all articles
Browse latest Browse all 232319

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>