VT's Blog

The Blog of Viral Tarpara A Smart 27 year old's thoughts on Windows, Cloud Computing, Collaboration, and Productivity

Powershell and OneNote - Are You Geek Enough?

Powershell and OneNote - Are You Geek Enough?

  • Comments 2
  • Likes

powershell onenote skills

 

I'll admit, when I saw OneNote and Powershell in the same headline, I was like WTF mate.  I started computing with command-line back with MSDOS, but somewhere between Windows XP and World of Warcraft, I just stopped caring about these outmoded nunchuck skillz.  Thankfully, Microsoft decided to go back to its roots and turn the Windows world upside down with Powershell...blah blah balh...

AND THEN...

Along comes Brian Dewey and turns my world upside down with the OneNote Powershell Provider.  Command line just officially became cool again!  He does some interesting things with Powershell scripting that is actually useful to the average person.  Below is an excerpt:

"Here’s an example: One thing I wanted was a tool that sends email when pages in a shared OneNote notebook change. This turned out to be pretty easy to do in PowerShell. With the OneNote PowerShell provider, the following lines of script get all of the pages that have changed after a particular time — I use this line in the script to find all pages that have changed since the last time I ran the script.

$changedPages = dir $Notebook -recurse | where-object { ([datetime]$_.lastModifiedTime -gt $targetDate) -and (!$_.PSIsContainer) } 

The dir -recurse command gets me a listing of all of the pages, sections, and section groups in the notebook.

The where-object clause is then used to whittle the list down to only pages (that’s the !$_.PSIsContainer bit) and only pages that have changed after $targetDate.

Then, I can use the following pipeline to export the changed OneNote pages to MHT format and remember the resulting filenames.

$exportedFileNames = $changedPages | export-onenote -output $outputDirectory -format mht | get-propertyvalue ExportedFile 

Finally, I use the Send-SMTPMail cmdlet from the PowerShell Community Extensions to send the email containing all of the changed pages."

After reading this I actually went and downloaded the Powershell as well as this provider thingy.  I feel like I'm 12 again.*yeah I don't have many friends*

--VT

Comments
  • Thanks for the kind words. When I get around to it, I hope to add this to the Powershell Community Extensions project. That should make it easier for people to use.

  • Long ago, when I had my first job in the IT industry, all the engineers I met carried hard-covered exercise

Your comment has been posted.   Close
Thank you, your comment requires moderation so it may take a while to appear.   Close
Leave a Comment