PowerCLI

 View Only
  • 1.  Suppress output from Initialize-PowerCLIEnvironment

    Posted Jun 06, 2019 03:17 PM

    I've written a report generator in PowerCLI then compiled it using ps2exe.ps1.

    The script calls Initialize-PowerCLIEnvironment.ps1. Everything works nicely except that I cannot specify -noconsole because that script has a number of write-host commands in it.

    Is there a simple way to suppress that output from Initialize-PowerCLIEnvironment.ps1?

    Any suggestions are appreciated.



  • 2.  RE: Suppress output from Initialize-PowerCLIEnvironment

    Posted Jun 06, 2019 04:23 PM

    Why would you call Initialize-PowerCLIEnvironment.ps1?

    Are you using a very old PowerCLI version?



  • 3.  RE: Suppress output from Initialize-PowerCLIEnvironment

    Posted Jun 06, 2019 05:11 PM

    I didn't know that I wasn't supposed to call Initialize-PowerCLIEnvironment

    I'm using PowerCLI 6.5



  • 4.  RE: Suppress output from Initialize-PowerCLIEnvironment

    Posted Jun 06, 2019 05:18 PM

    I would advise to upgrade to the latest version.
    The primary reason being that PowerCLI is modules only (no more PSSnapin), installed from the PowerShell Gallery and later versions contain bug fixes, performance improvements and new features.
    See Welcome PowerCLI to the PowerShell Gallery – Install Process Updates for instructions on how to upgrade.

    With the latest version (all modules) and when you are using PS v4 or higher, you profit from the module autoload feature.
    A module is automatically loaded the 1st time you use a cmdlet from that module.

    There still will be an annoying output when module VMware.PowerCLI is loaded (see also Eliminate, or provide option with | VMware PowerCLI ).
    But since there are no cmdlets in that module (it's a wrapper to load all other PowerCLI modules), the autoload feature will not load that module.



  • 5.  RE: Suppress output from Initialize-PowerCLIEnvironment

    Posted Jun 06, 2019 05:22 PM

    Thank you very much.

    I appreciate you taking the time to enlighten me.



  • 6.  RE: Suppress output from Initialize-PowerCLIEnvironment

    Posted Jun 06, 2019 07:46 PM

    No problem, let me know how it goes.



  • 7.  RE: Suppress output from Initialize-PowerCLIEnvironment

    Posted Jun 07, 2019 06:00 PM

    I installed PowerCLI 11.2 from a web site called PowerShell Gallery. Would you happen to know how to uninstall it?

    Several things stopped working.  There is nothing to uninstall in Programs and Features. I removed all of the modules in Powershell but it still reports that it's running 11.2.  I don't know where it put it and I can't figure out how to get rid of it.

    Once again, I will appreciate any suggestions.



  • 8.  RE: Suppress output from Initialize-PowerCLIEnvironment

    Posted Jun 07, 2019 06:12 PM

    The modules are installed in one of the directories that are shown $env:PSModulePath (separated with a semi-column).

    With the following you can find where the PowerCLI modules are installed

    Get-Module -Name VMware* -ListAvailable

    Since PS modules are nothing more than folders and files, you can just delete the folders related to each PowerCLI module.

    Now stop/start your PS session, and the PowerCLI modules are gone.

    What exactly stopped working when you installed PowerCLI 11.2.0?



  • 9.  RE: Suppress output from Initialize-PowerCLIEnvironment

    Posted Jun 07, 2019 06:40 PM

    I made a very big mistake getting into this now. I'm slammed with multiple critical projects at the moment and don't have the spare cycles to look into this.  I need to get things working again with 6.5 and then circle back and do this update the right way in the not distant future.  I guess, truth be told, I am delinquent for not having done this a year or two ago.

    There were a few things that didn't work right away. I had gotten most corrected. This was still puzzling me.

    I've got several VM's with a "/" in the name.  In the older version:

          Get-VM ($M.Name).Replace("/", "%2F")

    worked nicely but not in 11.2.

    It seems as though it should have been a trivial fix but I've run out of time.



  • 10.  RE: Suppress output from Initialize-PowerCLIEnvironment

    Posted Jun 07, 2019 07:37 PM

    Then just remove 11.2.0 (as I described above) and reinstall 6.5