I want to write and use scripts that require the PowerCLI commands. As long as they are run from the special "PowerCLI icon", all is well. They'll run just fine. However, I'd like to be able to simply run them from any command line, like this:
.\Create-TestingBoxen.ps1
I can have the script itself call & 'C:\Program Files (x86)\VMware\scripts\Initialize-PowerCLIEnvironment.ps1' itself, but that will fail if my script is run on anything not using the standard install.
I might be able to find a standardized registry key that will give me the install location of the initialization script, but that still leaves an unsightly mess when the script runs. The initialization script prints out a bunch of coloured text that serves as an "into to PowerCLI".
Also, it's better if scripts don't leave a bunch of unrelated stuff loaded when they terminate. As near as I can tell, that strategy leaves all the PowerCLI stuff loaded into whatever terminal was used to run the script. I'd like scripts to be encapulated.
All this stuff is really standard stuff for scripts, so I figure that lots of people have figured this problem out already. I'm pretty new to Powershell scripting (with lots of background in *nix shell scripts), so I'm hoping there's just something obvious that I'm not seeing. Otherwise, what things have y'all done to encapsulate your scripts so they can be used anywhere that PowerCLI is installed?