param([string] $siteCollectionUrl, [string] $LeasingRelUrl)
$currentScriptName = $MyInvocation.MyCommand.Name
$usageText = "`nUsage:`n .\"
$usageText += "$currentScriptName `"`<siteCollectionUrl>`" `"`<siteUrl>`"`n`n"
$usageText += "Where:`n"
$usageText += "siteCollectionUrl is the URL of the root site collection, e.g. http://sharepoint2010.com`n"
$usageText += "MORelUrl is the path of the site, e.g. testsite`n"
if ($siteCollectionUrl -eq "") {
write-Host -foregroundcolor Red "Required parameter siteCollectionUrl missing."
write-Host $usageText
exit
}
if ($LeasingRelUrl -eq "") {
write-Host -foregroundcolor Red "Required parameter MORelUrl missing."
write-Host $usageText
exit
}
$web = get-spweb "$siteCollectionUrl/$Url"
$pubWeb = [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($web)
function AddHeading($HeadingName,$Link)
{
$CreateSPNavigationNode = [Microsoft.SharePoint.Publishing.Navigation.SPNavigationSiteMapNode]::CreateSPNavigationNode
$qlNav = $pubWeb.Navigation.CurrentNavigationNodes
$headingNode = $CreateSPNavigationNode.Invoke($HeadingName, $Link, [Microsoft.SharePoint.Publishing.NodeTypes]::Heading, $qlNav)
$headingNode.Properties["Audience"] = ";;;;Group_Name"
$headingNode.Update()
$web.Update()
}
function AddLink($HeadingName,$DisplayName,$URL,$External)
{
Start-Sleep -Seconds 5
$qlNav1 = $web.Navigation.QuickLaunch
$qlNav1 | select Title, ID
$qlink = $qlNav1 | where {$_.Title -eq $HeadingName}
$linkNode = New-Object Microsoft.SharePoint.Navigation.SPNavigationNode($DisplayName,$URL,$External)
$qlink.Children.AddAsLast($linkNode)
}
AddHeading "TestHeading" ""
AddLink "TestHeading" "TestLink" "http://hotmail.com" "True"
$currentScriptName = $MyInvocation.MyCommand.Name
$usageText = "`nUsage:`n .\"
$usageText += "$currentScriptName `"`<siteCollectionUrl>`" `"`<siteUrl>`"`n`n"
$usageText += "Where:`n"
$usageText += "siteCollectionUrl is the URL of the root site collection, e.g. http://sharepoint2010.com`n"
$usageText += "MORelUrl is the path of the site, e.g. testsite`n"
if ($siteCollectionUrl -eq "") {
write-Host -foregroundcolor Red "Required parameter siteCollectionUrl missing."
write-Host $usageText
exit
}
if ($LeasingRelUrl -eq "") {
write-Host -foregroundcolor Red "Required parameter MORelUrl missing."
write-Host $usageText
exit
}
$web = get-spweb "$siteCollectionUrl/$Url"
$pubWeb = [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($web)
function AddHeading($HeadingName,$Link)
{
$CreateSPNavigationNode = [Microsoft.SharePoint.Publishing.Navigation.SPNavigationSiteMapNode]::CreateSPNavigationNode
$qlNav = $pubWeb.Navigation.CurrentNavigationNodes
$headingNode = $CreateSPNavigationNode.Invoke($HeadingName, $Link, [Microsoft.SharePoint.Publishing.NodeTypes]::Heading, $qlNav)
$headingNode.Properties["Audience"] = ";;;;Group_Name"
$headingNode.Update()
$web.Update()
}
function AddLink($HeadingName,$DisplayName,$URL,$External)
{
Start-Sleep -Seconds 5
$qlNav1 = $web.Navigation.QuickLaunch
$qlNav1 | select Title, ID
$qlink = $qlNav1 | where {$_.Title -eq $HeadingName}
$linkNode = New-Object Microsoft.SharePoint.Navigation.SPNavigationNode($DisplayName,$URL,$External)
$qlink.Children.AddAsLast($linkNode)
}
AddHeading "TestHeading" ""
AddLink "TestHeading" "TestLink" "http://hotmail.com" "True"
No comments:
Post a Comment