6

Possible Duplicate:
What’s the difference between Add-PsSnapIn and Import-Module

What is the difference between Add-PSSnapin and Import-Module in PowerShell?

At the end, both seem like they provide the same result.

Which one is the recommended approach?

Community
  • 1
  • 1
Samselvaprabu
  • 16,830
  • 32
  • 144
  • 230
  • 1
    I recommend http://www.simple-talk.com/dotnet/.net-tools/further-down-the-rabbit-hole-powershell-modules-and-encapsulation/. No info on plugins, just modules, which IIUC are the recommended approach for everything except MS legacy code (like SQL plugin, and TFS plugin). – yzorg Jun 07 '12 at 05:49
  • Clean and crisp - http://blogs.technet.com/b/aviraj/archive/2011/12/04/powershell-using-modules-and-snap-ins-what-s-the-difference-between-modules-amp-snap-ins.aspx – Angshuman Agarwal Jun 07 '12 at 08:47

1 Answers1

9

PsSnapins are the old fashion way (existing inPowerShell V1) to add CmdLet or Providers (but still in use)

  • They need to be registered (with installutil.exe tool)
  • They are assemblies written in one of the .NET language

Modules are the new way (added in PowerShel V2) to add CmdLet or Providers

  • They just have to be joinable on the file system (see $env:psmodulepath)
  • They may be scripts written in PowerShell (for CmdLet only) or assemblies for CmdLet and Providers written with one of the .NET language
  • It exists a manifest form that allow to specify much information about the creator, but also the dependancies on PowerShell versions, Framework version or other modules or assemblies version.

    I think that you can use module unless you have to support existing PowerShell V1 computers.

JPBlanc
  • 70,406
  • 17
  • 130
  • 175