PowerShell中的Add-PSSnapin和Import-Module有什么区别?

Sam*_*abu 6 powershell pssnapin import-module

可能重复:
Add-PsSnapIn和Import-Module之间有什么区别

Add-PSSnapinImport-ModulePowerShell有什么区别?

最后,两者似乎都提供了相同的结果.

推荐的方法是哪一种?

JPB*_*anc 9

PsSnapins是旧时尚方式(现有inPowerShell V1)添加CmdLet或提供者(但仍在使用中)

  • 他们需要注册(使用installutil.exe工具)
  • 它们是用.NET语言编写的程序集

模块是添加CmdLet或Providers的新方法(在PowerShel V2中添加)

  • 它们只需要在文件系统上可以连接(参见$ env:psmodulepath)
  • 它们可能是用PowerShell编写的脚本(仅适用于CmdLet),也可能是使用.NET语言编写的CmdLet和Providers的程序集
  • 它存在一个清单表单,允许指定有关创建者的大量信息,以及PowerShell版本,Framework版本或其他模块或程序集版本的依赖性.

    我认为您可以使用模块,除非您必须支持现有的PowerShell V1计算机.