none
Powershell: Activate "Show Subsites" in SharePoint Online RRS feed

  • Question

  • Hey guys,

    I'm currently looking for a way to activate the option "Show Subsites" in site navigation with Powershell. Therefore it's for SharePoint Online and not onPrem, all hints on google didn't work for me. So I hope anyone here can help me.

    The structure is planned as following:
    0. Landing Page
    1. Business Units
    1.1. CEO
    1.2. Marketing
    1.3. HR
    2. Customers
    2.1. Customer 1
    2.2 Customer 2
    3. Search

    So the nodes 0, 1 and 2 needs this checked option. 1 and 2 already inherit navigation options from node 0 with

    SPOCmdlets\Get-SPOWeb -web $ctx.web -WebUrl "SITETITLE" | Set-SPONavigationInherits
    What do I miss? Is it really so hard to check this option?


    Tuesday, January 10, 2017 9:44 AM

Answers

  • Hi,

     

    It’s not friendly for us to check the error as it’s not in English.

    I’m trying to check the error and seems the GetTaxonomySession got error, have you import necessary dlls?

    Add-Type -Path (Resolve-Path "Microsoft.SharePoint.Client.Taxonomy.dll")

    Add-Type-Path(Resolve-Path"Microsoft.SharePoint.Client.Publishing.dll")

    Below code is working based on my test.

    #Credentials to connect to office 365 site collection url 
    $url ="https://xxx.sharepoint.com/sites/lee/"
    $username="user@xxx.onmicrosoft.com"
    $password="pw"
    $Password = $password |ConvertTo-SecureString -AsPlainText -force
    
    Write-Host "Load CSOM libraries" -foregroundcolor black -backgroundcolor yellow
    Set-Location $PSScriptRoot
    Add-Type -Path (Resolve-Path "C:\Program Files\Common Files\microsoft shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll")
    Add-Type -Path (Resolve-Path "C:\Program Files\Common Files\microsoft shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll")
    Add-Type -Path (Resolve-Path "C:\Program Files\Common Files\microsoft shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Taxonomy.dll")
    Add-Type -Path (Resolve-Path "C:\Program Files\Common Files\microsoft shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Publishing.dll")
    
    Write-Host "CSOM libraries loaded successfully" -foregroundcolor black -backgroundcolor Green 
    
    Write-Host "authenticate to SharePoint Online Tenant site $url and get ClientContext object" -foregroundcolor black -backgroundcolor yellow  
    $Context = New-Object Microsoft.SharePoint.Client.ClientContext($url) 
    $credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($username, $password) 
    $Context.Credentials = $credentials 
    $context.RequestTimeOut = 5000 * 60 * 10;
    $web = $context.Web
    $site = $context.Site 
    $context.Load($web)
    $context.Load($site)
    try
    {
      $context.ExecuteQuery()
      Write-Host "authenticateed to SharePoint Online Tenant site $url and get ClientContext object succeefully" -foregroundcolor black -backgroundcolor Green
    }
    catch
    {
      Write-Host "Not able to authenticateed to SharePoint Online $_.Exception.Message" -foregroundcolor black -backgroundcolor Red
      return
    }
    
    #set both current and global navigation settings to structural
    Write-Host "set both current and global navigation settings to structural started" -foregroundcolor black -backgroundcolor yellow
    $taxonomySession = [Microsoft.SharePoint.Client.Taxonomy.TaxonomySession]::GetTaxonomySession($context)
    $navigationSettings = New-Object Microsoft.SharePoint.Client.Publishing.Navigation.WebNavigationSettings $context, $context.Web
    
    #set both current and global navigation settings to structural
    $navigationSettings.CurrentNavigation.Source = "portalProvider"
    $navigationSettings.GlobalNavigation.Source = "portalProvider"
    
    #For Display the same navigation items as the parent site
    #$navigationSettings.CurrentNavigation.Source = "inheritFromParentWeb"
    #$navigationSettings.GlobalNavigation.Source = "inheritFromParentWeb"
    
    #For Managed Navigation
    #$navigationSettings.CurrentNavigation.Source = "taxonomyProvider"
    #$navigationSettings.GlobalNavigation.Source = "taxonomyProvider"
    
    $navigationSettings.Update($taxonomySession)
    
    try
    {
    $Context.ExecuteQuery()
    Write-Host "setting both current and global navigation settings to structural Completed" -foregroundcolor black -backgroundcolor green
    }
    catch
    {
    Write-Host "Error while setting both current and global navigation settings to structural" $_.Exception.Message -foregroundcolor black -backgroundcolor Red
    }
    
    
    #disable quick launch navigation including subsites and pages    
    $context.Load($web.AllProperties)
    $Context.ExecuteQuery()
    $web.AllProperties["__IncludeSubSitesInNavigation"] = "True"
    $web.Update()
    $Context.ExecuteQuery()

     

    Best Regards,

    Lee


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    • Marked as answer by Florian Adler Wednesday, January 25, 2017 7:28 AM
    Friday, January 20, 2017 1:22 AM

All replies

  • Hi,

     

    Try with below script.

    Here is the thread for your reference.

    http://sharepoint.stackexchange.com/questions/202858/navigation-settings-csom-powershell-for-sharepoint-online

    #Credentials to connect to office 365 site collection url 
    $url ="https://tenant.sharepoint.com/sites/home"
    $username="user@tenant.onmicrosoft.com"
    $password="yourpassword"
    $Password = $password |ConvertTo-SecureString -AsPlainText -force
    
    Write-Host "Load CSOM libraries" -foregroundcolor black -backgroundcolor yellow
    Set-Location $PSScriptRoot
    Add-Type -Path (Resolve-Path "Microsoft.SharePoint.Client.dll")
    Add-Type -Path (Resolve-Path "Microsoft.SharePoint.Client.Runtime.dll")
    Add-Type -Path (Resolve-Path "Microsoft.SharePoint.Client.Taxonomy.dll")
    Add-Type -Path (Resolve-Path "Microsoft.SharePoint.Client.Publishing.dll")
    
    Write-Host "CSOM libraries loaded successfully" -foregroundcolor black -backgroundcolor Green 
    
    Write-Host "authenticate to SharePoint Online Tenant site $url and get ClientContext object" -foregroundcolor black -backgroundcolor yellow  
    $Context = New-Object Microsoft.SharePoint.Client.ClientContext($url) 
    $credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($username, $password) 
    $Context.Credentials = $credentials 
    $context.RequestTimeOut = 5000 * 60 * 10;
    $web = $context.Web
    $site = $context.Site 
    $context.Load($web)
    $context.Load($site)
    try
    {
      $context.ExecuteQuery()
      Write-Host "authenticateed to SharePoint Online Tenant site $url and get ClientContext object succeefully" -foregroundcolor black -backgroundcolor Green
    }
    catch
    {
      Write-Host "Not able to authenticateed to SharePoint Online $_.Exception.Message" -foregroundcolor black -backgroundcolor Red
      return
    }
    
    #set both current and global navigation settings to structural
    Write-Host "set both current and global navigation settings to structural started" -foregroundcolor black -backgroundcolor yellow
    $taxonomySession = [Microsoft.SharePoint.Client.Taxonomy.TaxonomySession]::GetTaxonomySession($context)
    $navigationSettings = New-Object Microsoft.SharePoint.Client.Publishing.Navigation.WebNavigationSettings $context, $context.Web
    
    #set both current and global navigation settings to structural
    $navigationSettings.CurrentNavigation.Source = "portalProvider"
    $navigationSettings.GlobalNavigation.Source = "portalProvider"
    
    #For Display the same navigation items as the parent site
    #$navigationSettings.CurrentNavigation.Source = "inheritFromParentWeb"
    #$navigationSettings.GlobalNavigation.Source = "inheritFromParentWeb"
    
    #For Managed Navigation
    #$navigationSettings.CurrentNavigation.Source = "taxonomyProvider"
    #$navigationSettings.GlobalNavigation.Source = "taxonomyProvider"
    
    $navigationSettings.Update($taxonomySession)
    
    try
    {
    $Context.ExecuteQuery()
    Write-Host "setting both current and global navigation settings to structural Completed" -foregroundcolor black -backgroundcolor green
    }
    catch
    {
    Write-Host "Error while setting both current and global navigation settings to structural" $_.Exception.Message -foregroundcolor black -backgroundcolor Red
    }
    
    
    // disable quick launch navigation including subsites and pages    
    $context.Load($web.AllProperties)
    $Context.ExecuteQuery()
    $web.AllProperties["__IncludeSubSitesInNavigation"] = "False"
    $web.Update()
    $Context.ExecuteQuery()
    
    $web.AllProperties["__IncludePagesInNavigation"] = "False"
    $web.Update()
    $Context.ExecuteQuery()
    
    #set dynamic child limit for current navigation
    $web.AllProperties["__CurrentDynamicChildLimit"] = 20
    $web.Update()
    $Context.ExecuteQuery()
    
    #set dynamic child limit for global navigation
    #$web.AllProperties["__GlobalDynamicChildLimit"] = 20
    #$web.Update()
    #$Context.ExecuteQuery()

    Best Regards,

    Lee


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Wednesday, January 11, 2017 6:17 AM
  • Hi Lee,

    thanks for your reply. I'll take a view in the upcoming days and will report next week.

    Cheers

    Friday, January 13, 2017 8:24 AM
  • Hi,

    Is any update for your issue?

    Best Regards,

    Lee


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Tuesday, January 17, 2017 8:40 AM
  • Hi Lee,

    Not so far, sorry. I hope I can give you feedback during this week...

    Cheers

    Tuesday, January 17, 2017 9:02 AM
  • Hi Lee, here are some news.

    I tried to implement it in my Powershell ang got several errors:

    authenticateed to SharePoint Online Tenant site https://tenant.sharepoint.com/sites/intranet and get ClientContext object succeefully
    set both current and global navigation settings to structural started
    Das Argument "context" mit dem Wert  "Microsoft.SharePoint.Client.ClientContext" für "GetTaxonomySession" kann nicht in den Typ "Microsoft.SharePoint.Client.ClientRuntimeContext" 
    konvertiert werden: "Der Wert "Microsoft.SharePoint.Client.ClientContext" vom Typ "Microsoft.SharePoint.Client.ClientContext" kann nicht in den Typ 
    "Microsoft.SharePoint.Client.ClientRuntimeContext" konvertiert werden."
    In Zeile:40 Zeichen:5
    +     $taxonomySession = [Microsoft.SharePoint.Client.Taxonomy.Taxonomy ...
    +     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : NotSpecified: (:) [], MethodException
        + FullyQualifiedErrorId : MethodArgumentConversionInvalidCastArgument
     
    New-Object : Für "WebNavigationSettings" und die folgende Argumenteanzahl kann keine Überladung gefunden werden: "2".
    In Zeile:41 Zeichen:27
    + ... nSettings = New-Object Microsoft.SharePoint.Client.Publishing.Navigat ...
    +                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidOperation: (:) [New-Object], MethodException
        + FullyQualifiedErrorId : ConstructorInvokedThrowException,Microsoft.PowerShell.Commands.NewObjectCommand
     
    Die Eigenschaft "Source" wurde für dieses Objekt nicht gefunden. Vergewissern Sie sich, dass die Eigenschaft vorhanden ist und festgelegt werden kann.
    In Zeile:44 Zeichen:5
    +     $navigationSettings.CurrentNavigation.Source = "portalProvider"
    +     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
        + FullyQualifiedErrorId : PropertyNotFound
     
    Die Eigenschaft "Source" wurde für dieses Objekt nicht gefunden. Vergewissern Sie sich, dass die Eigenschaft vorhanden ist und festgelegt werden kann.
    In Zeile:45 Zeichen:5
    +     $navigationSettings.GlobalNavigation.Source = "portalProvider"
    +     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
        + FullyQualifiedErrorId : PropertyNotFound
     
    Es ist nicht möglich, eine Methode für einen Ausdruck aufzurufen, der den NULL hat.
    In Zeile:51 Zeichen:5
    +     $navigationSettings.Update($taxonomySession)
    +     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
        + FullyQualifiedErrorId : InvokeMethodOnNull
     
    setting both current and global navigation settings to structural Completed
    Info: Creating Bereiche

    The function looks like this:

    function new-spOnlineWebBereiche {
        #variables that needs to be set before starting the script
        $siteURL = $url
        $webURL = "Bereiche0"
        $title = "Bereiche"
        $template = "STS#0"
        $useSamePermissionsAsParentSite = $true
             
        #Creating client context object
        $context = New-Object Microsoft.SharePoint.Client.ClientContext($siteURL)
        $context.credentials = $SPOCredentials
         
        #create web using WebCreationInformatin object (wci)
        $wci = New-Object Microsoft.SharePoint.Client.WebCreationInformation 
        $wci.url = $webURL
        $wci.title = $title
        $wci.webtemplate = $template
        $wci.useSamePermissionsAsParentSite = $useSamePermissionsAsParentSite
        $createWeb = $context.web.webs.add($wci)
        $context.load($createWeb)
    
        #try adding navigation options
        $web = $context.Web
        $site = $context.Site 
        $context.Load($web)
        $context.Load($site)
        try
            {
            $context.ExecuteQuery()
            Write-Host "authenticateed to SharePoint Online Tenant site $url and get ClientContext object succeefully" -foregroundcolor black -backgroundcolor Green
        }
        catch
            {
            Write-Host "Not able to authenticateed to SharePoint Online $_.Exception.Message" -foregroundcolor black -backgroundcolor Red
            return
        }
    
        #set both current and global navigation settings to structural
        Write-Host "set both current and global navigation settings to structural started" -foregroundcolor black -backgroundcolor yellow
        $taxonomySession = [Microsoft.SharePoint.Client.Taxonomy.TaxonomySession]::GetTaxonomySession($context)
        $navigationSettings = New-Object Microsoft.SharePoint.Client.Publishing.Navigation.WebNavigationSettings $context, $context.Web
    
        #set both current and global navigation settings to structural
        $navigationSettings.CurrentNavigation.Source = "portalProvider"
        $navigationSettings.GlobalNavigation.Source = "portalProvider"
    
        #For Display the same navigation items as the parent site
        #$navigationSettings.CurrentNavigation.Source = "inheritFromParentWeb"
        #$navigationSettings.GlobalNavigation.Source = "inheritFromParentWeb"
    
        $navigationSettings.Update($taxonomySession)
    
        try
            {
            $Context.ExecuteQuery()
            Write-Host "setting both current and global navigation settings to structural Completed" -foregroundcolor black -backgroundcolor green
        }
        catch
            {
            Write-Host "Error while setting both current and global navigation settings to structural" $_.Exception.Message -foregroundcolor black -backgroundcolor Red
        }
    
    
        #// disable quick launch navigation including subsites and pages    
        $context.Load($web.AllProperties)
        $Context.ExecuteQuery()
        $web.AllProperties["__IncludeSubSitesInNavigation"] = "False"
        $web.Update()
        $Context.ExecuteQuery()
    
        $web.AllProperties["__IncludePagesInNavigation"] = "False"
        $web.Update()
        $Context.ExecuteQuery()
    
        #set dynamic child limit for current navigation
        $web.AllProperties["__CurrentDynamicChildLimit"] = 20
        $web.Update()
        $Context.ExecuteQuery()
         
        #send the request containing all operations to the server
        try{
            $context.executeQuery()
            write-host "Info: Creating $($title)" -foregroundcolor green
            Add-SPOUser -Site $siteURL -Group "Besitzer von Intranet" -LoginName "Geschaeftsfuehrung"
            Add-SPOUser -Site $siteURL -Group "Mitglieder von Intranet" -LoginName "Abteilungsleitung"
            Add-SPOUser -Site $siteURL -Group "Besucher von Intranet" -LoginName "Jeder"
        }
        catch{
            write-host "info: $($_.Exception.Message)" -foregroundcolor red
        }
    
    }

    Maybe you know what went wrong?


    Thursday, January 19, 2017 8:04 AM
  • Hi,

     

    It’s not friendly for us to check the error as it’s not in English.

    I’m trying to check the error and seems the GetTaxonomySession got error, have you import necessary dlls?

    Add-Type -Path (Resolve-Path "Microsoft.SharePoint.Client.Taxonomy.dll")

    Add-Type-Path(Resolve-Path"Microsoft.SharePoint.Client.Publishing.dll")

    Below code is working based on my test.

    #Credentials to connect to office 365 site collection url 
    $url ="https://xxx.sharepoint.com/sites/lee/"
    $username="user@xxx.onmicrosoft.com"
    $password="pw"
    $Password = $password |ConvertTo-SecureString -AsPlainText -force
    
    Write-Host "Load CSOM libraries" -foregroundcolor black -backgroundcolor yellow
    Set-Location $PSScriptRoot
    Add-Type -Path (Resolve-Path "C:\Program Files\Common Files\microsoft shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll")
    Add-Type -Path (Resolve-Path "C:\Program Files\Common Files\microsoft shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll")
    Add-Type -Path (Resolve-Path "C:\Program Files\Common Files\microsoft shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Taxonomy.dll")
    Add-Type -Path (Resolve-Path "C:\Program Files\Common Files\microsoft shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Publishing.dll")
    
    Write-Host "CSOM libraries loaded successfully" -foregroundcolor black -backgroundcolor Green 
    
    Write-Host "authenticate to SharePoint Online Tenant site $url and get ClientContext object" -foregroundcolor black -backgroundcolor yellow  
    $Context = New-Object Microsoft.SharePoint.Client.ClientContext($url) 
    $credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($username, $password) 
    $Context.Credentials = $credentials 
    $context.RequestTimeOut = 5000 * 60 * 10;
    $web = $context.Web
    $site = $context.Site 
    $context.Load($web)
    $context.Load($site)
    try
    {
      $context.ExecuteQuery()
      Write-Host "authenticateed to SharePoint Online Tenant site $url and get ClientContext object succeefully" -foregroundcolor black -backgroundcolor Green
    }
    catch
    {
      Write-Host "Not able to authenticateed to SharePoint Online $_.Exception.Message" -foregroundcolor black -backgroundcolor Red
      return
    }
    
    #set both current and global navigation settings to structural
    Write-Host "set both current and global navigation settings to structural started" -foregroundcolor black -backgroundcolor yellow
    $taxonomySession = [Microsoft.SharePoint.Client.Taxonomy.TaxonomySession]::GetTaxonomySession($context)
    $navigationSettings = New-Object Microsoft.SharePoint.Client.Publishing.Navigation.WebNavigationSettings $context, $context.Web
    
    #set both current and global navigation settings to structural
    $navigationSettings.CurrentNavigation.Source = "portalProvider"
    $navigationSettings.GlobalNavigation.Source = "portalProvider"
    
    #For Display the same navigation items as the parent site
    #$navigationSettings.CurrentNavigation.Source = "inheritFromParentWeb"
    #$navigationSettings.GlobalNavigation.Source = "inheritFromParentWeb"
    
    #For Managed Navigation
    #$navigationSettings.CurrentNavigation.Source = "taxonomyProvider"
    #$navigationSettings.GlobalNavigation.Source = "taxonomyProvider"
    
    $navigationSettings.Update($taxonomySession)
    
    try
    {
    $Context.ExecuteQuery()
    Write-Host "setting both current and global navigation settings to structural Completed" -foregroundcolor black -backgroundcolor green
    }
    catch
    {
    Write-Host "Error while setting both current and global navigation settings to structural" $_.Exception.Message -foregroundcolor black -backgroundcolor Red
    }
    
    
    #disable quick launch navigation including subsites and pages    
    $context.Load($web.AllProperties)
    $Context.ExecuteQuery()
    $web.AllProperties["__IncludeSubSitesInNavigation"] = "True"
    $web.Update()
    $Context.ExecuteQuery()

     

    Best Regards,

    Lee


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    • Marked as answer by Florian Adler Wednesday, January 25, 2017 7:28 AM
    Friday, January 20, 2017 1:22 AM
  • I'm sorry Lee, but my client is German, so my Powershell is too.

    I tried to translate the error message in a manner so you might understand it better than using Google Translate. ;)

    The argument "context" with the value  "Microsoft.SharePoint.Client.ClientContext" for "GetTaxonomySession" cannot be converted into the type "Microsoft.SharePoint.Client.ClientRuntimeContext": "The value "Microsoft.SharePoint.Client.ClientContext" from type "Microsoft.SharePoint.Client.ClientContext" cannot be converted into 
    "Microsoft.SharePoint.Client.ClientRuntimeContext"."
    In C:\Intranet\Create Base Intranet Draft v1.1.ps1:315 Char:1
    + $taxonomySession = [Microsoft.SharePoint.Client.Taxonomy.TaxonomySess ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : NotSpecified: (:) [], MethodException
        + FullyQualifiedErrorId : MethodArgumentConversionInvalidCastArgument
     
    New-Object : For "WebNavigationSettings" and the following argumentcount there is no overloading: "2".
    In C:\Intranet\Create Base Intranet Draft v1.1.ps1:316 Char:23
    + ... nSettings = New-Object Microsoft.SharePoint.Client.Publishing.Navigat ...
    +                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidOperation: (:) [New-Object], MethodException
        + FullyQualifiedErrorId : ConstructorInvokedThrowException,Microsoft.PowerShell.Commands.NewObjectCommand
     
    The property "Source" was not found.
    In C:\Intranet\Create Base Intranet Draft v1.1.ps1:319 Char:1
    + $navigationSettings.CurrentNavigation.Source = "portalProvider"
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
        + FullyQualifiedErrorId : PropertyNotFound
     
    It's not possible to call a method with the value null.
    In C:\Intranet\Create Base Intranet Draft v1.1.ps1:330 Char:1
    + $navigationSettings.Update($taxonomySession)
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
        + FullyQualifiedErrorId : InvokeMethodOnNull


    The only thing I changed in your script was the path to the DLL files:

    Import-Module MsOnline
    Import-Module SPOCmdlets
    Import-Module SPOMod
    Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll"
    Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
    Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Taxonomy.dll"
    Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Publishing.dll"

    That's all. I think I didn't implement it right in the function, but where's the mistake? Is there something missing or is it "just" the wrong DLL?


    Friday, January 20, 2017 10:34 AM
  • Hi, 

    Could you try to test with an existing site and check whether the script works for you, if not work, try to download latest dlls and check.

    Here is the link for your reference.

    https://www.nuget.org/packages/Microsoft.SharePointOnline.CSOM

     

    If the script works fine for existing site, try to check the script of creating site is working fine.

     

    Best Regards,

    Lee


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Monday, January 23, 2017 1:48 AM
  • Hi Lee,

    your script (as it is) works fine. So I think I missed a point in implementing it. We will see, but you already helped me a lot. Thanks so far!

    Wednesday, January 25, 2017 7:28 AM