title: OneNote create Page with UpdateHierarchy - how to find new page?
body: <p>I managed to create sections at very specific places within my OneNote Notebooks. Now I want to achieve the same with pages. So instead of using the unpredicteable-placing "CreateNewPage" method, I use UpdateHierarchy which works perfectly fine (for testing purpose I'm using AppendChild below).</p>
  
  <p>The only issue I'm having is, that after creating the new page using UpdateHierarchy I'm completely loosing any links to the newly created page. OneNote assigns an ID and ignores all further Tags/Names I give. Also setting the One:T member used for setting the title is getting ignored - it always creates an "Untitled Page".</p>
  
  <p>Am I doing anything wrong or do I need to first CreateNewPage and, using the assigned page-ID, re-place it using UpdateHierarchy? </p>
  
  <p>Regards
  Joel</p>
  
  <pre><code>function createPage {
  param([string]$title, [string]$sectionnode)
  
  [string]$pageref=$null
  
  # Gather the pages within the notebook
  [xml]$ref = $null
  $_globalOneNote["COM"].GetHierarchy($sectionnode,  [Microsoft.Office.InterOp.OneNote.HierarchyScope]::hsPages, [ref]$ref)
  
  [System.Xml.XmlNamespaceManager] $nsmgr = $ref.NameTable
  $nsmgr.AddNamespace('one', "http://schemas.microsoft.com/office/onenote/2010/onenote")
  
  # Creation of a new page
  $newPage = $ref.CreateElement('one', 'Page', 'http://schemas.microsoft.com/office/onenote/2010/onenote')
  $newTitle = $ref.CreateElement('one', 'Title', 'http://schemas.microsoft.com/office/onenote/2010/onenote')
  $newOE = $ref.CreateElement('one', 'OE', 'http://schemas.microsoft.com/office/onenote/2010/onenote')
  $newT = $ref.CreateElement('one', 'T', 'http://schemas.microsoft.com/office/onenote/2010/onenote')
  
  $newPage.SetAttribute('name', "Olololo")
  $newT.InnerText = '&lt;![CDATA[Testtitle]]&gt;'
  
  $newOE.AppendChild($newT)
  $newTitle.AppendChild($newOE)
  $newPage.AppendChild($newTitle)
  
  $ref.Section.AppendChild($newPage)
  $_globalBJBOneNote["COM"].UpdateHierarchy($ref.OuterXML)
  }
  </code></pre>