if(-not(
Get-PSSnapin | Where { $_.Name -eq "Microsoft.SharePoint.PowerShell"})
) {
Add-PSSnapin Microsoft.SharePoint.PowerShell;
}
$Url = "http://sp2013:5559/"
$web = Get-SPWeb $Url;
$CreateNavigationNodeMethod = [Microsoft.SharePoint.Publishing.Navigation.SPNavigationSiteMapNode]::CreateSPNavigationNode
#Add Test4 link
$headingNode = $CreateNavigationNodeMethod.Invoke("Test4","/SitePages/Test4.aspx", [Microsoft.SharePoint.Publishing.NodeTypes]::AuthoredLinkPlain, $web.Navigation.TopNavigationBar)
$headingNode.Properties["Audience"]=";;;;" +"Test1"
$headingNode.Update()
#Add Test3 link
$headingNode = $CreateNavigationNodeMethod.Invoke("Test3","/SitePages/Test3.aspx", [Microsoft.SharePoint.Publishing.NodeTypes]::AuthoredLinkPlain, $web.Navigation.TopNavigationBar)
$headingNode.Properties["Audience"]=";;;;" +"Test,Test1"
$headingNode.Update()
#Add Dropdown
$Heading="Test Name Dropdown"
$CreateNavigationNodeMethod = [Microsoft.SharePoint.Publishing.Navigation.SPNavigationSiteMapNode]::CreateSPNavigationNode
$headingNode = $CreateNavigationNodeMethod.Invoke($Heading, [System.String]::Empty, [Microsoft.SharePoint.Publishing.NodeTypes]::Heading, $web.Navigation.TopNavigationBar)
$headingCollection = $headingNode.Children
$linkNode = $CreateNavigationNodeMethod.Invoke("Test Dropdown", "/_layouts/ApplicationPages/Test.aspx", [Microsoft.SharePoint.Publishing.NodeTypes]::AuthoredLinkPlain,$headingCollection)
$linkNode.Properties["Audience"]=";;;;" +"Test2,Test3"
$linkNode.Update()
Get-PSSnapin | Where { $_.Name -eq "Microsoft.SharePoint.PowerShell"})
) {
Add-PSSnapin Microsoft.SharePoint.PowerShell;
}
$Url = "http://sp2013:5559/"
$web = Get-SPWeb $Url;
$CreateNavigationNodeMethod = [Microsoft.SharePoint.Publishing.Navigation.SPNavigationSiteMapNode]::CreateSPNavigationNode
#Add Test4 link
$headingNode = $CreateNavigationNodeMethod.Invoke("Test4","/SitePages/Test4.aspx", [Microsoft.SharePoint.Publishing.NodeTypes]::AuthoredLinkPlain, $web.Navigation.TopNavigationBar)
$headingNode.Properties["Audience"]=";;;;" +"Test1"
$headingNode.Update()
#Add Test3 link
$headingNode = $CreateNavigationNodeMethod.Invoke("Test3","/SitePages/Test3.aspx", [Microsoft.SharePoint.Publishing.NodeTypes]::AuthoredLinkPlain, $web.Navigation.TopNavigationBar)
$headingNode.Properties["Audience"]=";;;;" +"Test,Test1"
$headingNode.Update()
#Add Dropdown
$Heading="Test Name Dropdown"
$CreateNavigationNodeMethod = [Microsoft.SharePoint.Publishing.Navigation.SPNavigationSiteMapNode]::CreateSPNavigationNode
$headingNode = $CreateNavigationNodeMethod.Invoke($Heading, [System.String]::Empty, [Microsoft.SharePoint.Publishing.NodeTypes]::Heading, $web.Navigation.TopNavigationBar)
$headingCollection = $headingNode.Children
$linkNode = $CreateNavigationNodeMethod.Invoke("Test Dropdown", "/_layouts/ApplicationPages/Test.aspx", [Microsoft.SharePoint.Publishing.NodeTypes]::AuthoredLinkPlain,$headingCollection)
$linkNode.Properties["Audience"]=";;;;" +"Test2,Test3"
$linkNode.Update()
No comments:
Post a Comment