I am trying to add a webPart on a SharePoint Online (Office 365) page using CSOM and PowerShell on a wiki page and that webPart always appears out of bounds like this:

[![](https://i.stack.imgur.com/jwsyw.png)](https://i.stack.imgur.com/jwsyw.png)

Code:

```
    $xmlDocument = Get-Content -Path "C:\Users\<censored>\desktop\table_matieres.webpart" -Raw

    $wpManager = $page.GetLimitedWebPartManager([System.Web.UI.WebControls.WebParts.PersonalizationScope]::Shared)
    $importWP = $wpManager.ImportWebPart($xmlDocument)

    $wp = $wpManager.AddWebPart($importWP.WebPart,0,0)
    $context.Load($wp)
    $context.ExecuteQuery()

```

Note: The table of contents is supposed to be on top of the site feed. The site layout got one top section and then one on the left and one on the right.

I am able, though, to remove webParts using the following code correctly:

```
    $list = $context.web.Lists.GetByTitle("Pages du site")
    $context.Load($list)
    $context.ExecuteQuery()
    $pages = $list.RootFolder.Files
    $context.Load($pages)
    $context.ExecuteQuery()
    $page = $list.RootFolder.Files | Where {$_.Name -eq "Accueil.aspx"}
    $context.Load($page)
    $context.ExecuteQuery()
    $wpm = $page.GetLimitedWebPartManager("Shared")
    $context.Load($wpm)
    $context.ExecuteQuery()
    $webParts = $wpm.WebParts
    $context.Load($webParts)
    $context.ExecuteQuery()

    $webPart = $webParts[0]
    $context.Load($webPart)
    $context.ExecuteQuery()
    $remove = $webPart.DeleteWebPart()
    $context.ExecuteQuery()
    $webPart = $webParts[2]
    $context.Load($webPart)
    $context.ExecuteQuery()
    $remove = $webPart.DeleteWebPart()
    $context.ExecuteQuery()`

```

After deleting (the startup webPart and the Documents webPart were removed from the top and the right section of the wiki zone correctly):

[![enter image description here](https://i.stack.imgur.com/38s7O.png)](https://i.stack.imgur.com/38s7O.png)

Is there a way to add the webPart directly in the correct zone through CSOM and PowerShell please?

Can you help me out with this one? This would be greatly appreciated.

Thank you in advance for your time and your help.