VMware Cloud Community
Boomer0007
Contributor
Contributor

How to stop/disable autoload of PowerShell modules?

Hello,

it may be nice for most people to have the PowerShell modules loaded as soon as i might type in something that seems to be a VMware cmdlet,

BUT I do have to deal with Citrix, Hyper-V and VMware in one Environment.

So it´s really annoying to get this behaviour pushed to me. Let me choose wether i like it or not please!

Best would be to have a cmdlet to configure the behaviour.

As Long as VMware does not follow the naming convention Guidelines for cmdlets i propose not to automatically load the modules!

If the typical commands for New- or Get-VM would be named like New-VmwareVM or Get-VmwareVM it would been better.

Does anyone else don´t like this?

Any idea how to get rid of it?

Thanks in advance!

Chris

5 Replies
AdrianTT
Enthusiast
Enthusiast

Hi Chris,

Are you referring to the Powershell Module Autoloading feature ? This behaviour is part of Powershell and not specific to PowerCLI however it can be disabled by executing the following:

$PSModuleAutoloadingPreference = “none”

For more infromation on the preference please refer to: https://msdn.microsoft.com/en-us/library/system.management.automation.psmoduleautoloadingpreference(...

Kind regards,

Adrian

Please consider marking this answer "correct" or "helpful" if you think your query have been answered correctly. Cheers,
LucD
Leadership
Leadership

Instead of loading the modules through auto-load, you could load them explicitly (for example from within your profile).

That would give you the optoin to specify a prefix. For example:

Get-Module -Name VMware* -ListAvailable | Import-Module -Prefix 'Vmw'

Now the nouns in the PowerCLI cmdlets all get this prefix, like for example: Connect-VmwViServer, Get-VmwVM...


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
Boomer0007
Contributor
Contributor

Hi, many thanks for your answers.

The problem is that the modules will be loaded automatically without notice.

I tried the $PSModuleAutoloadingPreference method but it seems to have no effect at all.

For example my code looks like this:

$PSModuleAutoloadingPreference = 'None'

$computer = "srv01"

Remove-Module vmware*

Import-Module Hyper-V

get-vm -ComputerName "srv01"

The output is a list of all my Hyper-V VMs. So far so good.

When I execute the cmd "get-vm -ComputerName "srv01" " alone it brings me this:

WARNING: Please consider joining the VMware Customer Experience Improvement Program, so you can help us make PowerCLI a better product. You can join using the following command:

Set-PowerCLIConfiguration -Scope User -ParticipateInCEIP $true

VMware's Customer Experience Improvement Program ("CEIP") provides VMware with information that enables VMware to improve its products and services, to fix problems, and to advise you on how best to deploy and use our products.  As part of the CEIP, VMware collects technical information about your organization’s use of VMware products and services on a regular basis in association with your organization’s VMware license key(s).  This information does not personally identify any individual.

For more details: type "help about_ceip" to see the related help article.

To disable this warning and set your preference use the following command and restart PowerShell:

Set-PowerCLIConfiguration -Scope User -ParticipateInCEIP $true or $false.

ERROR: Get-VM : A parameter cannot be found that matches parameter name 'ComputerName'.

MoveIT_OneGlass-PSScriptImporter.ps1 (38, 8): ERROR: At Line: 38 char: 8

ERROR: + get-vm -ComputerName "srv01"

ERROR: +        ~~~~~~~~~~~~~

ERROR:     + CategoryInfo          : InvalidArgument: (:) [Get-VM], ParameterBindingException

ERROR:     + FullyQualifiedErrorId : NamedParameterNotFound,VMware.VimAutomation.ViCore.Cmdlets.Commands.GetVM

ERROR:

This is totally weird. 😞

Cheers

Chris

0 Kudos
LucD
Leadership
Leadership

Try placing the $PSModuleAutoloadingPreference = 'None' in your profile file.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
jpsider
Expert
Expert

Why not move the modules out of the Modules folder?

0 Kudos