Hii All can anyone help me to Add links in the global navigation in sharepoint 2013 using powershell
How To Add Global Navigation through the PowerShell in share point 2010
Create a links.csv file and store it in local drivers like C:\solutions\links.csv. Store the link title and link url in the csv file.
Create a powershell ps1 file and store it in C:\script\Set-SPGlobalNav.ps1.
The script for the ps1 file is like this:
function Set-SPGlobalNav {
[CmdletBinding()]
param(
[Parameter(Mandatory=$true, ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$True)]
[Microsoft.SharePoint.PowerShell.SPWebPipeBind]$Site,
[string]$Heading,
[string]$Links
)
BEGIN {
Add-PSSnapin microsoft.sharepoint.powershell -ErrorAction SilentlyContinue
}
PROCESS {
$web = $site.Read()
$CreateNavigationNodeMethod = [Microsoft.SharePoint.Publishing.Navigation.SPNavigationSiteMapNode]::CreateSPNavigationNode
Write-Host “`nAdding
the Heading Node: ” $Heading;
$headingNode = $CreateNavigationNodeMethod.Invoke($Heading, [System.String]::Empty, [Microsoft.SharePoint.Publishing.NodeTypes]::Heading, $web.Navigation.TopNavigationBar)
$headingCollection = $headingNode.Children
$inputFile = Import-CSV $Links
foreach($row in $inputFile) {
Write-Host “Adding the Link: ” $row.LinkTitle
$linkNode = $CreateNavigationNodeMethod.Invoke($row.LinkTitle, $row.LinkURL, [Microsoft.SharePoint.Publishing.NodeTypes]::AuthoredLinkPlain, $headingCollection)
$linkNode.Update()
}
}
}
Call Script and Verify Results
For my given scenario, I want to add a new heading and various links to every site in the entire site collection. To perform this task I would use the below command:
Get-SPSite http://sp2010:5000/ | Get-SPWeb -Limit All | Set-SPGlobalNav -Heading “New Heading” -Links “c:\solutions\links.csv”
FinalResult
For More Information Go to Below Links
By
Deepak chauhan