Mshsnapin (part 1): usage of mshsnapin commands.


Latest beta3 release of monad added the capability of adding/removing cmdlets and providers in current running session through mshsnapins. Mshsnapin is a logic group of cmdlets and providers can be manipulate as a unit in monad engine.


Following commands can be used for manipulating mshsnapins,



  • get-mshsnapin: this will list all mshsnapin’s that are loaded in current monad session.
  • get-mshsnapin -reg: this will list all mshsnapin’s that are installed on current machine.
  • add-mshsnapin <mshsnapin-name>: this will load a mshsnapin into current monad session.
  • remove-mshsnapin <mshsnapin-name>: this will unload a mshsnapin from current monad session.

– George


Comments (9)

  1. Jesse Harris says:

    Will add-mshsnapin <http:\strComputermshsnapin-name>

    Work?

  2. It’s very cool that we can load cmdlets and providers into the runspace at runtime now. I think we have all longed for this.

    How persistent are these snapins? Can I now specify a list of snapins to load at startup to my RunspaceConfiguration?

    Does this solve the versioning problems that outed the old old "enumerate cmdlets at startup" method?

  3. Rahul says:

    What exactly does that term stand for?

  4. OK, I see that the SingleShell does provide a way to restore default snapins, and the versioning issue is taken care of.

  5. MSDNArchive says:

    [Response to comment 511421.]

    Jesse,

    Currently mshsnapin’s have to be installed on the local machine to be usable by monad.

    During the design phases we did think about supporting mshsnapin’s installed on remote machines. But we didn’t fully understand the implications on how to load mshsnapin assemblies from remote machine.

    This is one on-going item we are discussing for v2 of monad.

    George Xie [MSFT]

    Monad Development

    Microsoft Corporation

    This posting is provided "AS IS" with no warranties, and confers no rights

  6. MSDNArchive says:

    [Response to comment 511939.]

    Mshsnapin stands for "SnapIn from Msh". Msh is the shell name for monad. "SnapIn" is a term to used for extensions. The concept is kind of similiar to "SnapIn" in mmc. We call it to be "MshSnapIn" instead of "SnapIn" to avoid confustion with MMC snapins.

    George Xie [MSFT]

    Monad Development

    Microsoft Corporation

    This posting is provided "AS IS" with no warranties, and confers no rights

  7. MSDNArchive says:

    [Response to comment 511538.]

    When you start monad, you can provide a monad console file (.mcf file). In this file, it has the mshsnapin’s that you want to load at monad start-up.

    Here are some simple steps to play with .mcf file,

    1. start a monad session by running msh.exe

    2. add some mshsnapin into monad session by running add-mshsnapin cmdlet.

    3. run export-console command and specify a file name (for example myconsole.mcf). This will save currently loaded monad snapins into console file.

    4. restart a monad session with command

    msh -m myconsole.mcf

    This will start monad session with all mshsnapins listed in myconsole.mcf.

    George Xie [MSFT]

    Monad Development

    Microsoft Corporation

    This posting is provided "AS IS" with no warranties, and confers no rights

  8. Will Irwin says:

    I found that once a snapin is added to the shell, its DLL file is locked by MSH.EXE for as long as that MSH.EXE process remains running.  Even after I do remove-mshsnapin and installutil -u on it, the file remains locked.   This is inconvenient for development – is there some other way to get MSH.EXE to let go of that file?