I m a novice in PowerShell. I have encountered a problem with importing modules. It seems that an installed module will be automatically imported when I try to invoke a cmdlet in this module.
That s is:
- If a module has been installed, such as
Install-Module -Name PSscriptAnalyzer
- Do not import it. Check it has not been imported:
Get-Module PSScriptAnalyzer # Show nothing
- Try to use a cmdlet in
PSScriptAnalyzer
:Invoke-ScriptAnalyzer -Path ./ -Recurse # Ignore any info
- Then the module
PSScriptAnalyzer
will be automatically imported:
It shows as the follows:Get-Module PSScriptAnalyzer
ModuleType Version PreRelease Name ExportedCommands ---------- ------- ---------- ---- ---------------- Script 1.21.0 PSScriptAnalyzer {Get-ScriptAnalyzerRule, Invoke-Formatter, Invoke-ScriptAnalyzer}
Why will the module be imported automatically as long as its ExportedCommands
have been imported? What is the mechanism it is?
And if so, the Remove-Module
doesn t seem to make much sense in general usage scenarios anymore.
提前感谢。