3

I am creating a new site in 2013 with powershell (New-SPWeb) and attempting to set some Search Navigation settings. The problem I encounter is that my Get-SPWeb call fails until I access the site via the browser. After that, the powershell commands work as expected. Does anyone have any insight as to what might be happening? There are no errors when I access the site via the browser and I am actually able to get the Get-SPWeb object but when I use it as follows, it gives me an error.

    $web = get-spweb http://sc.mysite.ca/TestNewSite
    $node = New-Object -TypeName "Microsoft.SharePoint.Navigation.SPNavigationNode" -ArgumentList "This Site", "/TestNewSite/template/_layouts/15/osssearchresults.aspx?u=http://sc.mysite.ca/TestNewSite", $true;
    $web.Navigation.SearchNav.AddAsFirst($node);

Error:

    You cannot call a method on a null-valued expression.
    At C:\scripts\Create-NewSite.ps1:984 char:1
    + $web.Navigation.SearchNav.AddAsFirst($node);
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

If I put a sleep command in before the $web.Navigation.SearchNav.AddAsFirst($node) call, then access the site via the browser, the program runs successfully. I have seen some posts referring to the fact that there may be an error with the front page, but I have no errors indicating any issues. I am using a standard template PROJECTSITE#0.

Some additional messages I have been able to narrow down from the logs:

CatalogConfig.ReadFromPropertyBag; Catalog configurations don't exist for site collection http://sc.mysite.ca/TestNewSite.

SiteServicesAddins.ReadFromPropertyBag: Site services addins don't exist for site collection http://sc.mysite.ca/TestNewSite.

Here is the output of the SPWeb object:

    Url
    ---
    http://sc.mysite.ca/TestNewSite

Here is the output of the $node1 object:

    Title                  :
    TitleResource          :
    IsVisible              :
    IsDocLib               :
    IsExternal             : True
    Id                     : 0
    ParentId               : 0
    Parent                 :
    Navigation             :
    Url                    : /TestNewSite/Project Template/_layouts/15/osssearchresults.aspx?u=http://sc.mysite.ca/TestNewSite
    LastModified           : 1/1/0001 12:00:00 AM
    Children               : {}
    Properties             :
    TargetSecurityScopeId  : 00000000-0000-0000-0000-000000000000
    TargetParentObjectType : Web

Here is the output of the $node2 object:

    Title                  :
    TitleResource          :
    IsVisible              :
    IsDocLib               :
    IsExternal             : True
    Id                     : 0
    ParentId               : 0
    Parent                 :
    Navigation             :
    Url                    : http://search.myite.ca/Pages/results.aspx
    LastModified           : 1/1/0001 12:00:00 AM
    Children               : {}
    Properties             :
    TargetSecurityScopeId  : 00000000-0000-0000-0000-000000000000
    TargetParentObjectType : Web
  • Also, Looking in the WFE logs when I access the site via the browser, I see the line: Populating navigation children for web, I'm guessing this may be related. – AMadKinnon Sep 28 '15 at 16:03
  • Hi, You cannot call a method on a null-valued expression. At + $w.Navigation.SearchNav.AddAsLast($node) + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [], RuntimeException + FullyQualifiedErrorId : InvokeMethodOnNull Any solutions? Regards, John – goso Oct 30 '15 at 9:01
1

I came across this thread when troubleshooting the following errors mentioned above:

CatalogConfig.ReadFromPropertyBag; Catalog configurations don't exist for site collection [mysiteURL]

SiteServicesAddins.ReadFromPropertyBag: Site services addins don't exist for site collection [mysiteURL]

My resolution was to enable two Site Collection Features:

  1. SharePoint Server Publishing Infrastructure
  2. SharePoint Server Standard Site Collection features

Managed Navigation is a SharePoint Publishing feature, so this may resolve the described issue as well. Try creating a new Publishing Site to test this.

The difference in SP 2013 Navigation options are described in the following article: Office Support Article

  1. In the Site Actions menu Site Actions Menu , click Site Settings.

  2. Look at the list of links on the Site Settings page under Look and Feel.

  3. If you see a link titled Navigation, then you are working with a publishing site and you can configure your site using the Navigation Settings page. Navigation

  4. If you see links titled Top link bar and Quick Launch, then you are working with a non-publishing site and you have a more limited set of navigation configuration options available to you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.