SHARE
TWEET

Untitled

a guest Sep 8th, 2017 110 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Add-PSSnapIn Microsoft.SharePoint.PowerShell
  2.  
  3. $containerCode = @"
  4. <div id='webTitleContainer' class='ms-core-brandingText'></div>
  5. <script type='text/javascript'>
  6. (function() {
  7.     // Set a default title to use if we cannot retrieve one.
  8.     var defaultTitle = '';
  9.  
  10.     // Ensure that both the DOM and the Object Model are ready for us
  11.     document.addEventListener('DOMContentLoaded', function() {
  12.         EnsureScriptFunc('sp.js', 'SP.ClientContext', function() {
  13.             // Get and load a reference to the root web of the current site collection.
  14.             var context = new SP.ClientContext.get_current();
  15.             var web = context.get_web();
  16.             context.load(web);    
  17.  
  18.            // Query SharePoint for the current sites title and URL
  19.             context.executeQueryAsync(function(){
  20.                  var title = web.get_title();
  21.                  var url = web.get_url();
  22.  
  23.                 // If the current site isn't the homepage then add the title and link of the current site to the top bar
  24.                  if(title != 'SharePoint Home' && title != 'Home') {
  25.                     document.getElementById('titleContainer').innerHTML = title;
  26.                     document.getElementById('currentSiteUrl').href = url;
  27.                     document.getElementById('titleDivider').style.display = 'inline'
  28.                     document.getElementById('titleContainer').style.display = 'inline';
  29.                  }
  30.               },
  31.               function(sender,args){
  32.                  console.log(args.get_message());
  33.               }
  34.             );
  35.         });
  36.     });
  37.  
  38.     function titleBarRenamer() {
  39.         // Get and load a reference to the root web of the current site collection.
  40.         var context = new SP.ClientContext.get_current();
  41.         var web = context.get_web();
  42.         context.load(web);    
  43.         context.executeQueryAsync(function(){
  44.             // Query for the current site title
  45.              var title = web.get_title();
  46.              var url = web.get_url();
  47.  
  48.              if(title != 'SharePoint Home' && title != 'Home') {
  49.                 document.getElementById('titleContainer').innerHTML = title;
  50.                 document.getElementById('currentSiteUrl').href = url;
  51.                 document.getElementById('titleDivider').style.display = 'inline'
  52.                 document.getElementById('titleContainer').style.display = 'inline';
  53.              }
  54.           },
  55.           function(sender,args){
  56.              console.log(args.get_message());
  57.           }
  58.         );
  59.     }
  60. })();
  61. </script>
  62. "@
  63.  
  64. $webApp = Get-SPWebApplication -Identity "*SharePointUrl*"
  65. $webApp.SuiteBarBrandingElementHtml = "<div class='ms-core-brandingText'><a href='*SharePointUrl*' style='color:#fff;'><img style='margin-bottom:-1px; padding-right:5px;' src='*fullLinkToImage*'>SharePoint Home</a><span id='titleDivider' style='display:none;'> - </span><a id='currentSiteUrl' href='#' style='color:#fff;'><span id='titleContainer' style='display:none;'>$containerCode</span></a></div>"
  66. $webApp.Update()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top