pssnapin question and OneNote

hello,
I have been trying to get Brian Dewey’s OneNote Provider to work (http://bdewey.com/2007/07/18/onenote-powershell-provider/). When I run the Enable-OneNote.ps1, I get a message that " No snap-ins have been registered for Windows PowerShell version 3.". The error message directs me to
Add-PSSnapin Microsoft.Office.OneNote. So now to my question, is the PSSnapin Microsoft.Office.OneNote a common snapin that should be available to me if I have OneNote installed? or should it be included in Brian’s msi?

thanks

Joe

Hi Joe,

OneNote doesn’t come with a PowerShell provider. You’ll need to install Brian’s MSI because snap-ins need to be registered in the Registry unlike modules. Brian’s MSI should handle the Registry registration for you.

Best,
Daniel

Thanks for the fast reply.
I uninstalled and reinstalled the OneNotePowershell.msi, ran the Enable-OneNote.ps1 and came up with the same error (Add-PSSnapin Microsoft.Office.OneNote not found).
I think I need to take a step back and ask a more Powershell centric question.
When I issue get-pssnapin on my laptop it shows that I have :

Name : Microsoft.PowerShell.Core

If I search my laptop for Microsoft.PowerShell.Core, nothing is found. But Microsoft.PowerShell.Core apparently is an installed snapin (module). So when I initially installed PSv3.0 the install process must have performed an add-pssnapin xxxxx to get the Microsoft.PowerShell.Core installed??

So does add-pssnapin xxxxx use xxxxx or is xxxxx an alias for another file??

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

I really appreciate all the help you’ve given me on this Daniel. Since the msi worked for you, I tried installing it on another workstation with the same results.
One interesting item, I looked under HKLM\Software\Microsoft\Powershell\1\ using regedit and I found the PowerShellSnapins entry,
however, when I tried using get-childitem (Get-ChildItem -Path registry::HKLM\SOFTWARE\Microsoft\PowerShell\1), the PowerShellSnapins key was not listed. Only keys listed are 0409, PowerShellEngine,PSConfigurationProviders, ShellIDs.
Should get-childitem -path registry:: list the same registry entries as whats listed in regedit?

hey Daniel,
brief follow up. Got a little more traction on my issue. During the install of the msi, the registry entries did not go under the
HKEY_LOCAL_MACHINE\software\microsoft\powershell\1 but were instead imported into
HKEY_LOCAL_MACHINE\Software\Wow6432Node\Microsoft\Powershell\1. So imported the key under the HKEY_LOCAL_MACHINE\software\microsoft\powershell\1 into HKEY_LOCAL_MACHINE\Software\Wow6432Node\Microsoft\Powershell\1\ and at least now I was able to add the pssnapin.

thanks again for your assistance, will keep plugging away at this.

btw I REALLY do not like training online, do you have any recommendation for a physical book for Powershell (beginner)?

thanks