Quantcast
Channel: PowerShell.org » All Posts
Viewing all articles
Browse latest Browse all 13067

Reply To: pssnapin question and OneNote

$
0
0

Joe,

No problem. Get-PSSnapin only shows snap-ins loaded into your current session.

PS C:\> Get-PSSnapin
 
 
Name        : Microsoft.PowerShell.Core
PSVersion   : 5.0.9740.0
Description : This Windows PowerShell snap-in contains cmdlets used to manage components of Windows PowerShell.

You need to tell Get-PSSnapin to show you the registered snap-ins.

PS C:\> Get-PSSnapin -Registered
 
 
Name        : Microsoft.Office.OneNote
PSVersion   : 2.0
Description : Provides cmdlets for managing OneNote notebooks.

Add-PSSnapin can only load already registered snap-ins. There is no cmdlet to register snap-ins as far as I know. An installer for a snap-in needs to add a Registry key and values under HKLM:\SOFTWARE\Microsoft\PowerShell\1\PowerShellSnapIns.

PS C:\> Get-ChildItem -Path HKLM:\SOFTWARE\Microsoft\PowerShell\1\PowerShellSnapIns
 
 
    Hive: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\PowerShellSnapIns
 
 
Name                           Property
—-                           ——–
Microsoft.Office.OneNote       PowerShellVersion : 2.0
                               Vendor            : Microsoft
                               Description       : Provides cmdlets for managing OneNote notebooks.
                               Version           : 1.5.0.2
                               ApplicationBase   : C:\Program Files (x86)\Microsoft.Office.OneNote.Commands
                               AssemblyName      : Microsoft.Office.OneNote.Commands, Version=1.5.0.2,
                               Culture=neutral,
                                                   PublicKeyToken=ef8691f3764be4ad
                               ModuleName        : C:\Program Files
                               (x86)\Microsoft.Office.OneNote.Commands\Microsoft.Office.OneNote.Commands.dll

I've downloaded and installed the OneNote PowerShell snap-in MSI which successfully registered the snap-in on my system.

PS C:\> Add-PSSnapin Microsoft.Office.OneNote
 
PS C:\> Get-Command -Module Microsoft.Office.OneNote
 
CommandType     Name                                               Source
———–     —-                                               ——
Cmdlet          Close-OneNote                                      Microsoft.Office.OneNote
Cmdlet          Export-OneNote                                     Microsoft.Office.OneNote
Cmdlet          Get-OneNoteHierarchy                               Microsoft.Office.OneNote
Cmdlet          Get-OneNoteHyperlink                               Microsoft.Office.OneNote
Cmdlet          Get-OneNotePageContent                             Microsoft.Office.OneNote
Cmdlet          Get-OneNoteTOC                                     Microsoft.Office.OneNote
Cmdlet          Open-OneNote                                       Microsoft.Office.OneNote
Cmdlet          Set-OneNotePageContent                             Microsoft.Office.OneNote

P.S. Microsoft.PowerShell.Core is a special case. This snap-in does not seem to be registered in the Registry and it is hosted in DLL which differs from the snap-in name.

PS C:\> Get-PSSnapin -Name Microsoft.PowerShell.Core | Format-List -Property *
 
 
Name                        : Microsoft.PowerShell.Core
IsDefault                   : True
ApplicationBase             : C:\Windows\System32\WindowsPowerShell\v1.0
AssemblyName                : System.Management.Automation, Version=3.0.0.0, Culture=neutral,
                              PublicKeyToken=31bf3856ad364e35, ProcessorArchitecture=MSIL
ModuleName                  : C:\Windows\System32\WindowsPowerShell\v1.0\System.Management.Automation.dll
PSVersion                   : 5.0.9740.0
Version                     : 3.0.0.0
Types                       : {types.ps1xml, typesv3.ps1xml}
Formats                     : {Certificate.format.ps1xml, DotNetTypes.format.ps1xml, FileSystem.format.ps1xml,
                              Help.format.ps1xml…}
Description                 : This Windows PowerShell snap-in contains cmdlets used to manage components of Windows
                              PowerShell.
Vendor                      : Microsoft Corporation
LogPipelineExecutionDetails : False

I hope above helps.

Best,
Daniel


Viewing all articles
Browse latest Browse all 13067

Trending Articles