我的盒子上安装了Powershell 3.
我需要使用Powershell 4测试一些脚本,但我想继续运行一些在Powershell 3下测试的脚本,我不想通过安装Powershell 4来破坏某些东西.
问题:尽管我已安装Powershell 4,是否可以在Powershell版本3下打开Powershell会话(如果需要,甚至可以打开2个)?
我是 PowerShell 的新手。我在导入模块时遇到了问题。当我尝试在该模块中调用 cmdlet 时,似乎会自动导入已安装的模块。
那是:
Install-Module -Name PSscriptAnalyzerGet-Module PSScriptAnalyzer
# Show nothing
Run Code Online (Sandbox Code Playgroud)
PSScriptAnalyzer:
Invoke-ScriptAnalyzer -Path ./ -Recurse
# Ignore any info
Run Code Online (Sandbox Code Playgroud)
PSScriptAnalyzer将自动导入:
Get-Module PSScriptAnalyzer
Run Code Online (Sandbox Code Playgroud)
显示如下:
ModuleType Version PreRelease Name
ExportedCommands
---------- ------- ---------- ---- ----------------
Script 1.21.0 PSScriptAnalyzer {Get-ScriptAnalyzerRule, Invoke-Formatter, Invoke-ScriptAnalyzer}
Run Code Online (Sandbox Code Playgroud)
为什么模块只要导入了就会自动导入呢ExportedCommands?它的机制是什么?如果是这样,那么Remove-Module在一般使用场景中似乎就没有多大意义了。
提前致谢。