📜  -AllowClobber - 任何代码示例

📅  最后修改于: 2022-03-11 14:59:34.759000             🧑  作者: Mango

代码示例1
What is clobbering?
By default when we use the Install-Module command (which is part of PowerShellGet or simply PSGet) to install a new module to the local system, it queries what commands are exported by the requested module and checks that list against all the existing modules already installed on the system to see if there are any conflicts, i.e. if any of the commands have the same name. If it finds any you will get an error and the installation will be aborted.

When to allow clobbering and is it safe?
In order to override the clobber-checking behavior you have explicitly specify the -AllowClobber parameter flag when installing a new module. This will allow the module to be installed, but you have to be aware that the last module imported wins when it comes to conflicting command names.
So if you have two modules with the same command exported, and both are imported into the current session, the one that is imported second will have its command exported last and thus it will be available in the session as the default command with that name.
This is safe as long as you are aware of it and intentionally override the default behavior, and you have to do this if you want to make use of the new module on the local system.