Skip to content

PowerShell module for manipulating Microsoft OneNote data using the Microsoft Graph REST API.

License

Notifications You must be signed in to change notification settings

wightsci/OneNoteUtilitiesGraph

Repository files navigation

OneNoteUtilitiesGraph

PowerShell module for manipulating Microsoft OneNote data using the Microsoft Graph REST API.

Following on from OneNoteUtilities this module uses the Microsoft Graph API instead of the desktop COM objects.

Update November 5, 2019

Following Microsoft's decision to continue support for the desktop version of OneNote I have added an additional command (Invoke-ONDesktop) to open OneNote pages in the desktop application specifically, rather than whichever application has been registered as the handler for the onenote: protocol.


This module provides the following functions:

Installation

Before installing the module, ensure that you have a client ID for the Microsoft Graph service. See the following for more information https://docs.microsoft.com/en-us/graph/auth-register-app-v2.

Create a config XML file containing your client ID and security scope information, named OneNoteUtilities.config and place it in your .config folder. There is a template file in this repo on GitHub.

Download the module, extract it to a location in your modules path and use Import-Module. The process of importing will trigger an attempt to connect to Microsoft Graph. This will fail if you haven't set up the config file.

Use Case - Creating Structure

Suppose that you need to create a new Notebook, create Sections for the months of the year and create a Page for each day of each month. You would like the title of each page to look like 'Friday, 26th June 2019' in format. With OneNoteUtiliesGraph you can do this:

Import-Module OneNoteUtilitiesGraph
#Create NoteBook
$NoteBook = New-ONNoteBook -DisplayName (Get-Date).Year
#Create Section per Month
(1..12) | % {
    $month = $_; 
    $monthName = (Get-Date -Month $_).ToString('MMMM')
    $Section = New-ONSection -Id $NoteBook.Id -DisplayName $monthName
    #Create Page per Day 
    (1..$([DateTime]::DaysInMonth((Get-Date).Year,$month))) | % {
            $Page = New-ONPageXML -Title $((Get-Date -Year (Get-Date).Year -Month $month -Day $_).toString("dddd dd MMMM yyyy"))
            New-ONPage -URI $Section.pagesURL -Page $Page
    }
}

It takes a couple of minutes, but that's much shorter than creating 12 month Sections and 365 day Pages by hand.

This could just as easily be applied to lists of staff, students or objects in Active Directory.

Use Case - Querying

Get-ONPages -Filter "parentNoteBook/displayname eq '2019' and startswith(title,'Monday')"

More use cases - see the Wiki

https://github.com/wightsci/OneNoteUtilitiesGraph/wiki

Future Developments

  • Support for Tags
  • HTML Templates for Pages
  • Merge-to-OneNote
  • Out-ONPage
  • New Graph REST features as they are released

About

PowerShell module for manipulating Microsoft OneNote data using the Microsoft Graph REST API.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published