2012-06-07 41 views
6

可能重複:
What’s the difference between Add-PsSnapIn and Import-ModulePowerShell中的Add-PSSnapin和Import-Module有什麼區別?

是什麼PowerShell中Add-PSSnapinImport-Module之間的區別?

最後,兩人似乎都提供了相同的結果。

哪一個是推薦的方法?

+1

我推薦http://www.simple-talk.com/dotnet/.net-tools/further-down-the-rabbit-hole-powershell-modules-and-encapsulation/。沒有關於插件的信息,只是模塊,對於除了MS遺留代碼(如SQL插件和TFS插件)以外的其他應用程序,IIUC是推薦的方法。 – yzorg

+0

乾淨清爽 - http://blogs.technet.com/b/aviraj/archive/2011/12/04/powershell-using-modules-and-snap-ins-what-s-the-difference-between-modules -AMP-管理單元ins.aspx –

回答

9

PsSnapins是舊時尚的方式(現有inPowerShell V1)添加cmdlet或供應商(但仍在使用)

  • 他們需要進行註冊(與installutil.exe工具)
  • 他們是集寫在.NET語言的一個

模塊是新的方式(在PowerShel V2添加)來添加cmdlet或供應商

  • 他們只需要在文件系統上可連接(見$ ENV:psmodulepath)
  • 它們可以是小命令(僅適用於cmdlet的)寫在PowerShell腳本或組件和提供具有的一個寫的。 NET語言
  • 它存在一個清單表單,它允許指定有關創建者的許多信息,但也包括PowerShell版本,Framework版本或其他模塊或程序集版本上的依賴關係。

    我認爲你可以使用模塊,除非你必須支持現有的PowerShell V1計算機。