Today With PowerShell – 2nd July, 2016

No posts for a while, for two main reasons.

  1. Lethargy
  2. Working on a PowerShell module – my first attempt at a module rather than a quick-and-dirty script.

All of this was triggered by an intersection of two of my favourite Microsoft products. PowerShell and OneNote (+ some lethargy).

I had been doing some work in PowerShell and wanted to capture the results in OneNote; preferably to a nice tabular layout. Something like:

Get-SomeObject | Out-OneNote

With the result being a nice new page containing a tabular representation of the objects in question. No dice I’m afraid. You can export to text, you can do a OneNote printout using the OneNote printer driver (resulting in an image) but you can’t pipe objects into OneNote.  I was too lazy to use any of the (complicated  in my view) workarounds – so it was time for a script.

I use the desktop version of OneNote by preference on PCs – so this meant I could avoid wrestling with REST and use a good old-fashioned COM API. This initial idea of Out-OneNote quickly became a set of utility functions for accessing the OneNote object model and the OneNoteUtilities module was born. At the moment I have a few different functions available. Here are some names to wet your appetites:

CommandType     Name                                               Version    Source
———–     —-                                               ——-    ——
Function        Get-ONHierarchy                                    0.0        OneNoteUtilities
Function        Get-ONNoteBook                                     0.0        OneNoteUtilities
Function        Get-ONNoteBooks                                    0.0        OneNoteUtilities
Function        Get-ONPage                                         0.0        OneNoteUtilities
Function        Get-ONPages                                        0.0        OneNoteUtilities
Function        Get-ONSections                                     0.0        OneNoteUtilities
Function        New-ONElement                                      0.0        OneNoteUtilities
Function        New-ONPage                                         0.0        OneNoteUtilities

The eventual aim will be to publish via GitHub and possibly the PowerShell Gallery.


OneNote developer reference

OneNote 2013 COM API XML Schema – OneNote 2013 XSD

W3 Schools XPath Intro

This entry was posted in PowerShell and tagged , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s