我想添加一个QuickLaunch链接到使用powershell的网站。
我当前使用的脚本是:
$web = Get-SPWeb http://sp_3/Deps
$node = New-Object -TypeName Microsoft.SharePoint.Navigation.SPNavigationNode
-ArgumentList "LinkTitle", "http://sp_3/Deps/SUP"
$web.Navigation.QuickLaunch.Add($node);
$web.Update()这将导致以下错误:
Can not find an overload for the "Add" and the number of arguments: "1." line: 1 char: 32
+ $ Web.Navigation.QuickLaunch.Add <<<< ($ node);
+ CategoryInfo: NotSpecified: (:) [], MethodException
+ FullyQualifiedErrorId: MethodCountCouldNotFindBest我做错了什么?
发布于 2012-11-22 07:13:01
啊!This page有最好的教程和例子。以下是对我有效的方法(SP 2010)
$quickLaunch = $currentWeb.navigation.quicklaunch
$libheading = $quickLaunch | where { $_.Title -eq "Libraries" }
$newnode = New-Object Microsoft.SharePoint.Navigation.SPNavigationNode($whattitle, $myurllink, $true)
$libheading.Children.AddAsLast($newnode)
$currentweb.update()发布于 2012-05-11 14:59:08
SPNavigationNodeCollection.Add方法需要第二个参数-一个现有的SPNavigationNode,以便将新添加的参数放在它后面。您可以查找一个by URL,例如,或通过枚举集合。或者干脆把新的放在前面(AddAsFirst)或后面(AddAsLast)。
$web.Navigation.QuickLaunch.AddAsLast($node)更新:如何将链接添加到站点组:
$quickLaunch = $web.Navigation.QuickLaunch
# Print the $quickLaunch collection and choose a property
# identifying the best the link group you want. I chose URL.
$sitesUrl = "/sites/team/_layouts/viewlsts.aspx"
$sitesGroup = $quickLaunch | Where-Object { $_.Url -eq $sitesUrl }
$sitesGroup.Children.AddAsLast($node)-费尔达
https://stackoverflow.com/questions/10545991
复制相似问题