How to get a page list of any section of OneNote from PowerShell?

To get a page list of any section of OneNote from PowerShell, you can use the following steps:

  1. Install the OneNote PowerShell module. You can do this by running the following command in PowerShell:
Install-Module OneNote

  1. Import the OneNote module. You can do this by running the following command in PowerShell:
Import-Module OneNote

  1. Get the list of sections in the notebook. You can do this by running the following command in PowerShell:
Get-OneNoteSection

  1. Select the section that you want to get a page list for. You can do this by using the Select-Object cmdlet. For example, to select the section named "My Notes", you would run the following command:
Select-Object -ExpandProperty Name -First 1 | Where-Object {$_ -eq "My Notes"}

  1. Get the list of pages in the selected section. You can do this by running the following command in PowerShell:
Get-OneNotePage -Section $section

This will return a list of all of the pages in the selected section. You can then use the Get-OneNotePage cmdlet to get more information about each page, such as the title, content, and creation date.

Here is an example of a complete PowerShell script that you can use to get a page list of any section of OneNote:

# Import the OneNote module
Import-Module OneNote

# Get the list of sections in the notebook
$sections = Get-OneNoteSection

# Select the section that you want to get a page list for
$section = Select-Object -ExpandProperty Name -First 1 | Where-Object {$_ -eq "My Notes"}

# Get the list of pages in the selected section
$pages = Get-OneNotePage -Section $section

# Print the list of pages
foreach ($page in $pages) {
    Write-Host $page.Title
}

This script will print a list of all of the pages in the "My Notes" section of OneNote.

When I ran Install-Module OneNote, No match was found for the specified search criteria and module name 'OneNote' error. How do I get this module?

The OneNote PowerShell module is not included in the default installation of PowerShell. To install it, you need to use the PowerShellGet package manager.

To install PowerShellGet, run the following command in PowerShell:

Install-Package PowerShellGet