In PowerCLI 6.5.1
, the Welcome to VMware PowerCLI
message will be returned if the module is manually loaded. This is by design.
However, if you allow the modules to automatically load, then you will not get a welcome message. Sounds good, but the problem is for people that always run a loader of some kind to bring in PowerCLI. They are getting unexpected welcome messages when they did not before.
The quick summary is that no loader is needed for 6.5.1 and greater. However, if you absolutely must deal with that welcome message, read on.
Supressing Welcome
To suppress the welcome message in VMware PowerCLI 6.5.1
, we have several choices:
- Do Nothing (this is preferred, auto-loading of modules returns no welcome message)
- Write a loader that handles versions (ok, not needed, except for backwards compatibility)
- Import PowerCLI using your $PROFILE (ok, for some cases)
- Unsupported: Replace the
VMware.PowerCLI.ps1
file (ok, but not recommended)
Let's look at each of the above options.
Option #1 - Do Nothing
After installing PowerCLI 6.5.1
(not to be confused with PowerCLI 6.5 R1
), modules will be imported automatically as needed. There is no welcome message unless you manually import modules.
Option #2 Replace Loader
If you want to handle older versions of PowerCLI that use PSSnapins, and be able to quietly load PowerCLI 6.5.1, you can use a snippet such as:
If(-Not(Get-Module -Name VMware.PowerCLI -ListAvailable)){
#old loader code here
}
The above will do nothing if it detects VMware.PowerCLI
(nomenclature of latest 6.5.1 module). Otherwise it will run the desired code (i.e. Add-PSSnapin
).
For an example that handles PowerCLI 5.0 to 6.5.1+ see my Invoke-PowerLoader.ps1 on github
Option #3 - Add to $PROFILE
In some cases, it may be sufficient to perform the import of PowerCLI from your PowerShell $PROFILE instead of inside the script in question. Since the welcome message only appears at first load, this may be good enough for interactive purposes.
Option #4 - Unsupported
This is unsupported, but does successfully suppress the welcome message without impacting anything. For this technique, we replace the VMware.PowerCLI.ps1
file. This is shown for academic purposes. I don't think anyone would want or need to do this.
Let's start by locating the PowerCLI module manifest with:
(Get-Module -Name VMware.PowerCLI -ListAvailable).Path
The above results in the following (on a default install):
'C:\Program Files\WindowsPowerShell\Modules\VMware.PowerCLI\6.5.1.5377412\VMware.PowerCLI.psd1'
Reviewing the above .psd1
we can see:
# Modules to import as nested modules of the module specified in ModuleToProcess
NestedModules= @('VMware.PowerCLI.ps1')
The actual .ps1
that contains the welcome message is a nested module named VMware.PowerCLI.ps1
and is located at:
'C:\Program Files\WindowsPowerShell\Modules\VMware.PowerCLI\6.5.1.5377412\VMware.PowerCLI.ps1'
Because the file itself is signed, you cannot change lines within the file. However, you can replace the file itself (as long as you keep the filename the same and keep the
$productName = "PowerCLI"
line).
Contents of VMware.PowerCLI.ps1
:
Contents of Replacement VMware.PowerCLI.ps1
:
We will make some changes inside the file and then save it with the same name. We will remove all other contents (including SIG). Only the following line should remain:
$productName = "PowerCLI"
This completes the unsupported tweak. The next time you launch PowerCLI by manually importing the module, it is quiet. Admittedly, this last option is overkill and is shown merely for completeness.
Summary
With PowerCLI 6.5.1, we should simply update our loaders to not exist (or handle versions).
The dilemma is that we want the compatibility of supporting old 5.x PowerCLI, but we don't want it spamming the welcome message when we run 6.5.1. It is a change, but mostly cosmetic.
The trick is to decide on a universal loader, or to remove loader logic completely (must commit to PowerCLI 6.5.1 across the board).