{"id":1850,"date":"2013-05-06T05:12:42","date_gmt":"2013-05-06T05:12:42","guid":{"rendered":"https:\/\/poiseddevelopers.com\/reality-tech\/?p=1850"},"modified":"2024-04-12T05:49:23","modified_gmt":"2024-04-12T05:49:23","slug":"adjusting-quicklinks-programmatically-in-sharepoint","status":"publish","type":"post","link":"https:\/\/poiseddevelopers.com\/reality-tech\/adjusting-quicklinks-programmatically-in-sharepoint\/","title":{"rendered":"Adjusting Quicklinks Programmatically in SharePoint"},"content":{"rendered":"<h2>Use PowerShell to set Quicklinks Programmatically in SharePoint<\/h2>\n<p>Wouldn\u2019t it be great to hide all lists of a certain type in a farm? Perhaps Tasks, Calendars or Discussions, or all of the above. Progrmmatically, they can be hidden or exposed on navigation using set_OnQuickLaunch(). Here\u2019s how a given library is hidden from quick launch:<\/p>\n<pre lang=\"php\">\r\n$LIB.set_OnQuickLaunch($false)\r\n<\/pre>\n<p>Let\u2019s now do it across a full web application; all the site collections, sites, and for a set of libraries.<\/p>\n<pre lang=\"php\">\r\nAdd-PSSnapin \"Microsoft.SharePoint.PowerShell\" -ErrorAction SilentlyContinue\r\nStart-SPAssignment \u2013Global \r\n \r\n$mylogfile=\"C:logfolderongoinglogfile.txt\"\r\n \r\n$envrun=\"Prod\"          # selects environment to run in\r\n   \r\nif ($envrun -eq \"Dev\")\r\n{\r\n$siteUrl = \"http:\/\/devdocs.SharePoint.com\"\r\n$LibsToFlip = \"Tasks,Site Pages,Calendar,Documents\"\r\n \r\n$LibsToFlipArray = $LibsToFlip.Split(\u201c,\u201d)\r\n}\r\nelseif ($envrun -eq \"Prod\")\r\n{\r\n$siteUrl = \"http:\/\/docsny.SharePoint.com\"\r\n \r\n$LibsToFlip = \"Tasks,Site Pages,Calendar,Documents,Team Discussion\"\r\n$LibsToFlipArray = $LibsToFlip.Split(\u201c,\u201d)\r\n}\r\nelse\r\n{\r\nWrite-Host \"ENVIRONMENT SETTING NOT VALID: script terminating...\"\r\n$siteUrl =  $null;\r\nreturn;\r\n}\r\n \r\nWrite-Host \"Quick Launch Flip script starting $(get-date)\"\r\n \r\n \r\n \r\nif ($siteurl)\r\n{\r\n$rootSite = New-Object Microsoft.SharePoint.SPSite($siteUrl)\r\n$spWebApp = $rootSite.WebApplication \r\nforeach($site in $spWebApp.Sites)\r\n{\r\n  write-host $site.Url\r\n \r\n#  if ($site.Url -like \"$siteurl\/personal\/*\")  \r\n  if ($site.Url -like \"$siteurl*\")  \r\n{\r\n$rootSite = New-Object Microsoft.SharePoint.SPSite($siteUrl);\r\n$rootWeb = $rootSite.RootWeb;\r\n \r\n \r\n $webs= $site.AllWebs;\r\n $WebsCount = $webs.count;\r\n  \r\n for ($wi=0; $wi -lt $WebsCount; $wi++)\r\n   {\r\n   $web = $webs[$wi]\r\n \r\n   $changed = $false;\r\n    \r\n   $lists = $web.Lists;\r\n   $listcount = $lists.count;\r\n    for ($li=0; $li -lt $listcount; $li++)\r\n   { \r\n   $JPLib = $lists[$li]\r\n \r\n    if ($libsToFlipArray -contains $JPLib.Title )\r\n    {\r\n    WRITE-HOST -ForegroundColor darkgreen \"$($JPLib.Title) in $($web.url)\"\r\n    $JPLIB.set_OnQuickLaunch($false)\r\n    $JPLib.Update()\r\n    $changed = $true;\r\n    }\r\n \r\n    }\r\n    if ($changed)\r\n    {\r\n        #$Web.update()\r\n    }\r\n  \r\n}\r\n}\r\n}\r\n}\r\n \r\nStop-SPAssignment \u2013Global\r\n###########################\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Use PowerShell to set Quicklinks Programmatically in SharePoint Wouldn\u2019t it be great to hide all lists of a certain type in a farm? Perhaps Tasks, Calendars or Discussions, or all of the above. Progrmmatically, they can be hidden or exposed on navigation using set_OnQuickLaunch(). Here\u2019s how a given library is hidden from quick launch: $LIB.set_OnQuickLaunch($false) [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":1854,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[53],"tags":[],"class_list":["post-1850","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-navigation"],"acf":[],"_links":{"self":[{"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/posts\/1850","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/comments?post=1850"}],"version-history":[{"count":1,"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/posts\/1850\/revisions"}],"predecessor-version":[{"id":1858,"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/posts\/1850\/revisions\/1858"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/media\/1854"}],"wp:attachment":[{"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/media?parent=1850"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/categories?post=1850"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/tags?post=1850"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}