What is the difference between Add-PSSnapin and Import-Module in PowerShell? [duplicate]
Asked Answered
L

1

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?

Lacreshalacrimal answered 7/6, 2012 at 5:40 Comment(2)
I recommend simple-talk.com/dotnet/.net-tools/…. No info on plugins, just modules, which IIUC are the recommended approach for everything except MS legacy code (like SQL plugin, and TFS plugin).Cuneiform
Clean and crisp - blogs.technet.com/b/aviraj/archive/2011/12/04/…Dishpan
G
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.

Golub answered 7/6, 2012 at 5:46 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.