To get a page list of any section of OneNote from PowerShell, you can use the following steps:
Install-Module OneNote
Import-Module OneNote
Get-OneNoteSection
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"}
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.
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