Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I am receiving the following error when attempting to add a Link to the Top Navigation Bar.

"Exception calling "AddAsLast" with "1" argument(s): "Access is denied"

Here is the code:

$web = Get-SPWeb $url.Url;

$newLink = New-Object Microsoft.SharePoint.Navigation.SPNavigationNode -ArgumentList  @($web.Title, $web.Url);  

$web.Navigation.TopNavigationBar.AddAsLast($newLink);
$web.Update();

looking for some reasons and work arounds. Thanks!

share|improve this question

1 Answer 1

up vote 1 down vote accepted

The syntax is fine, I run the exact same code and it works without a problem.

Some things to look at:

  • Does your account have the right level of access? I know, probably silly question, but just checking
  • What does the ULS log say when you're running this command?
  • Try wrapping in an SPSecurity.RunWithElevatedPrivileges({}) statement
  • Try some more simple cases (get the web then update it immediately without adding anything to the navigation bar to verify navigation is part of the problem)
share|improve this answer
    
Thanks for checking this for me. The trick for me was to run my powershell window using an account capable of adding top nav links –  ChiliYago Jan 11 '11 at 0:31

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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