Pages are towards the bottom of the hierarchy in OneNote – though we still haven’t dived into the content of pages yet.
You can find the pages in your notebooks like this:
$onenote = New-Object -ComObject OneNote.Application
$scope = [Microsoft.Office.Interop.OneNote.HierarchyScope]::hsPages
[ref]$xml = ”
$onenote.GetHierarchy($null, $scope, $xml)
$schema = @{one="http://schemas.microsoft.com/office/onenote/2013/onenote"}
$xpath = "//one:Notebook/one:Section"
Select-Xml -Xml ([xml]$xml.Value) -Namespace $schema -XPath $xpath |
foreach {
$psitem.Node.Name
}
There’s one drawback to this – all you get is the page names:
PowerShell Summit
Comedy
Personal information
Book Series
AD
Applications
CCNA
Exchange
Infrastructure Architecture
Operations
Security
Hyper-V
WMI
PS Deep Dive
Deep Dive US12
You need to play around with Xpath a bit more to get a meaningfiul structure – ideally notebook – section – page