Close

BLOGS

Top 10 things/tasks a SharePoint Admin should know

Confirm you have Database backups of all the SQL DB’s that power SharePoint

SharePoint stores all it’s content in “Content Databases” – It is critical to get these backed up, daily. Sure there are other databases that are important too, but if you do nothing else, make sure the content databases are being backed up. Most companies have a DBA that manages/guards the SQL Server, so you may want to run GET-SPCONTENTDATABASE and give the output to your DBA for confirmation.  Also note that it’s possible to kick off some backup jobs from Central admin but you have to be careful – If you’re environment is using 3rd party tools like K2, Nintex, Newsgator, etc.. it’s very likely that the central admin backup will Not backup those.  Anyhow in your second or third week on the job you can dig more into backups and such, but for now,  at least make sure the content databases are backed up.

 

Capture basic user permissions so you have a record in case some one messes up.

The most common problem here, is that a user with enough rights hits the “inherit permissions” button, which resets the permissions on their website and often leaves them unable to do anything. When this happens, it’s nice to have a way to verify that they were the site owner before this happened, and icing on the cake is if you have a full record of what the permissions were before.


Use a SharePoint warmup script

SharePoint, which uses .net on top of IIS, suffers from a “Slow first launch” problem – the first time you access a site – .net does a bunch of “just in time” mumbo jumbo, that slows your site to a crawl. If you’ve ever logged into central admin and had to wait 60 seconds or more for it to come up, you’ve experienced this.  The easy solution to this, is to have a script access the site every 15-30 minutes this way the site is always loaded in memory and ready to go.

 

Use scripts for WSP deployments

If you EVER have to deploy WSP’s that your developers provide, you will save yourself HOURS of time if you have them provide you a deployment script along with the WSP.

$packages = (dir *.wsp | Select-Object name)  
$currentDir = (Get-Location).Path  
Add-PSSnapin Microsoft.Sharepoint.PowerShell -ErrorAction "SilentlyContinue" 
Start-SPAssignment -Global    # This cmdlet takes care of the disposable objects to prevent memory leak. 
Write-Host "Started package installation"

function WaitForJobToFinish ([string]$solutionName)    
{
     $JobName = "solution-deployment-$solutionName*"    
     $job = Get-SPTimerJob | ?{ $_.Name -like $JobName }    
 if ($job -eq $null)     
 {
         Write-Host "Timer job not found"
 }else
 {
  $JobFullName = $job.Name        
  Write-Host -NoNewLine "Waiting to finish job $JobFullName"            
  while ((Get-SPTimerJob $JobFullName) -ne $null)         
  {
   Write-Host -NoNewLine .
          Start-Sleep -Seconds 2        
  }
  Write-Host  "Finished waiting for job.."    
 }
}

foreach ($i in $packages)  
{  
    Write-Host -NoNewLine "Waiting for deployment jobs to finish..."            
    while ((Get-SPTimerJob  | ?{$_.Name -like "solution-deployment*"}) -ne $null)         
    {
     Write-Host -NoNewLine .
     Start-Sleep -Seconds 2        
    }
    Write-Host  "Finished waiting for job.."    
    Write-Host "Retracting: " + $i  
    $solution = (Get-SPSolution | where-object {$_.Name -eq $i.Name})  
    Write-Host $solution.Name  
    if ($solution -ne $null)  
    {  
      Write-Host "Solution Found..." 
     if ($solution.Deployed -eq $true)  
     {  
      Write-Host "Uninstalling..."
      try
      {
       Uninstall-SPSolution -Identity $i.Name -AllWebApplications -Confirm:$false
      }catch
      {
       Uninstall-SPSolution -Identity $i.Name -Confirm:$false  
      }
     }
     Write-Host "Retract Completed!" 
     Write-Host "Removing Solution..." 
     do{
  Write-Host -NoNewLine .
             Start-Sleep -Seconds 2
     }
     until ($solution.Deployed -eq $false)
     WaitForJobToFinish $i.Name
            Start-Sleep -Seconds 5
     Remove-SPSolution -Identity $i.Name -Force -Confirm:$false 
     Write-Host "Remove Completed!" 
    }  
    else 
    {  
     Write-Host "Expected: Packaged not installed" 
    }  
}  
foreach ($i in $packages) 
{  
    Write-Host "Deploying: " + $i  
    $solution = (Get-SPSolution | where-object {$_.Name -eq $i.Name})  
    if ($solution -eq $null)  
    {  
     Write-Host "Adding Solution..." 
     $solution = Add-SpSolution -LiteralPath ($currentDir + $i.Name)  
     WaitForJobToFinish $solution.Name
     Write-Host "Deployment Completed!" 
     Write-Host "Installing Solution..."
     try{
  Write-Host "Installing for web application(s)"
         Install-SPSolution -Identity $solution.Name -allwebapplications -GACDeployment -CASPolicies
      }
     catch 
     {
  Install-SPSolution -Identity $solution.Name -GACDeployment -CASPolicies
     }
    }  
}

 

Stop-SPAssignment -Global    # This cmdlet takes care of the disposable objects to prevent memory leak.

Remove-PsSnapin Microsoft.SharePoint.Powershell

 

How to flush the SharePoint timer service cache.

The SharePoint Timer service is that windows service that runs on each machine in the farm – it’s job is to query the DB looking for work – this could be WSP deployment jobs, or it could be  “timer jobs” or whatever.  The timer service uses a cache and sometimes it gets confused, and clearing the cache will help the issue.

The problem with solutions containing timer jobs is that, if the timer job cache is not cleared across all servers in the farm, the timer job may continue running code from an older assembly which has been uninstalled but simply remained cached. The SharePoint timer job cache is also often called the SharePoint Configuration Cache.

This script can be run on any server in a multi-server SharePoint farm. But it needs to be executed by a farm administrator.

# Get the local farm instance
[Microsoft.SharePoint.Administration.SPFarm]$farm = [Microsoft.SharePoint.Administration.SPFarm]::get_Local()
 
# Stop the SharePoint Timer Service on each server in the farm
StopSharePointTimerServicesInFarm $farm
 
# Delete all xml files from cache config folder on each server in the farm
DeleteXmlFilesFromConfigCache $farm
 
# Clear the timer cache on each server in the farm
ClearTimerCache $farm
 
# Start the SharePoint Timer Service on each server in the farm
StartSharePointTimerServicesInFarm $farm

 

Inject yourself as a site collection admin into every site collection in your farm (Including all your mysites)

Nothing worse than getting a call from someone wanting help with SharePoint, and you don’t have access to their site. Sure you can go into central admin and put your name in there, but it only holds two names, so if you have a team of 3 people, that’s not good enough. The script below lets you add as many people as you want to the Site collection administrator group of each site collection.

# set site collection owner for all sites...
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
 
# $AccountList is an array of Windows Identities in the format of $AccountList = @("DOMAIN\USERID" , "DOMAIN\absuser")
$AccountList = @("lab\abc", "lab\pqr", "lab\efg", "lab\lmn")
 
#this gets an array of objects representing the sites at the IIS level:
$IISSites = Get-SPWebApplication
Foreach($oneIISSite in $IISSites)
{
   #using .Sites, we can get a list of the site collections
   foreach ($SharepointSiteCollection in $oneIISSite.Sites)
   {
      write-host $SharepointSiteCollection.url -ForegroundColor Cyan
      $spweb = Get-SPWeb $SharepointSiteCollection.url
      
      #now we have the website, so lets look at each account in our array
      foreach ($Account in $AccountList)
      {
         #lets see if the user already exists
         Write-host "Looking to see if User " $account " is a member on " $SharepointSiteCollection.url -foregroundcolor Blue
         $user = Get-SPUSER -identity $Account -web $SharepointSiteCollection.url -ErrorAction SilentlyContinue #This will throw an error if the user does not exist
         if ($user -eq $null)
         {
            #if the user did NOT exist, then we will add them here.
            $SPWeb.ALLUsers.ADD($Account, "", "", "Added by AdminScript")
            $user = Get-SPUSER -identity $Account -web $SharepointSiteCollection.url
            Write-host "Added user $Account to URL $SPWeb.URL" -Foregroundcolor Magenta
         }
         else
         {
            Write-host "user $Account was already in URL " $SPWeb.URL -Foregroundcolor
DarkGreen
         }
         if ($user.IsSiteAdmin -ne $true)
         {
            $user.IsSiteAdmin = $true
            $user.Update()
            Write-host "$account has been made an admin on $SPWeb.URL" -Foregroundcolor
Magenta
         }
else
         { 
         Write-host "$account was already an admin on $SPWeb.URL" -Foregroundcolor DarkGreen
         }
     }
     $SharePointSiteCollection.Dispose()
}
}


Adding Additional Farm Admins to an Existing Farm by us AD Group

- To start off, create an AD Group for SharePoint administrators. We’ll use “SharePoint Server Admins” as the name.

- Add the “SharePoint Server Admins” AD Group to the BuiltIn\administrators group on each server in the farm.the (BUILTIN\Administrators) group is already referenced in both the Farm Administrators group in Central Administration and the local WSS_Admin_WPG group as shown in the following two figures:

  • - Central Administration Site > Security > Manage the farm administrators group
  • - Go to Computer Management -> Local Users and Groups -> Groups -> WSS_Admin_WPG group
  • Check whether BUILTIN\Administrators groups is avialable or not
  • - Open SQL Management Studio and add the “SharePoint Server Admins” group as a server login with dbcreator, public, and sysadmin server roles as documented here.
  • -  In the properties of the new SQL login created, go to he User Mappings section. In the mapped databases select the central administration and config databases and ensure that public and db_owner role memberships are checked. For the config database you will also want to select the SharePoint_Shell_Access role membership to give farm administrators the access to execute PowerShell against the farm.
  • -  Add the new farm admins to the “SharePoint Server Admins” AD Group.
  • - Additionally, if you want to give administrator access to the site collections created,  add the “SharePoint Server Admins” group to the Site collection administrators of each site collection. Note that to add a domain security group in the site collection administration group in SharePoint Foundation 2010 you need to apply KB 2597136 which was just released today.

 

Enable versioning on every list and document library on your farm.

SharePoint versioning feature tracks changes, so that you can View document or item's version history and audit/recover them if needed.

  • Go to your document library >> Click the Library tab on the Ribbon >> Click on Library Settings.
  • Under general Settings, click Versioning Settings link.
  • From the Versioning Settings page, choose "Create major versions". Optionally, you can set a limit on number of versions. 

Enable versioning for all document libraries using PowerShell

Add-PSSnapin microsoft.sharepoint.powershell -ErrorAction SilentlyContinue
 
$webURL="http://demo.crescent.com"
#Get the Web
$web = Get-Spweb $webURL
 
#Get all lists - Exclude System lists
$ListColl = $web.lists | Where-Object  { ($_.hidden -eq $false) -and ($_.IsSiteAssetsLibrary -eq $false) -and ($_.BaseType -eq "DocumentLibrary") }
 
foreach($list in $ListColl)
 {
    if ($list.EnableVersioning -eq $false)
    {
        #Enable Versioning Settings
        $list.EnableVersioning = $true
        $list.MajorVersionLimit = 5 #No. of versions - versioning best practices
        $list.EnableMinorVersions = $true #Applicable only to Libraries
        $list.MajorWithMinorVersionsLimit = 5 #No. of Drafts in Lists
 
        $list.Update()
        write-host Versioning enabled for: $list.RootFolder.URL
    }
}

This script enables versioning programmatically in the entire site.

 

Export all the WSP’s from your farm.

If you ever need to rebuild the farm from scratch, you’ll want a copy of all the sharepoint solutions that were installed -these are stored in WSP files and getting a copy of them is so easy, that it just makes sense to do that now.  As a result here we can save additional efforts and time to recreate solution by reusing WSP file.
Export all WSP'sPowerShell

Get-SpSolution | forEach-Object {
$_.SolutionFile.SaveAs(“C:exportedWSP$($_.Name)”)
}

 

Connect to all your servers as your admin account at one time with PowerShell

It’s a good practice to have two windows ID’s – one for yourself and one for the admin work you do, that way you’re less likely to make accidental mistakes. In my enviornment, my admin ID has access to over 40 different servers. But when I log in each day at my desk, I log in with my non-admin account. When it comes time to patching or copying files to a bunch of different servers, typing in my admin account and password gets old pretty fast. This script will log in your admin account to as many servers as you’d like – once conected, you can go right to them without entering any credentials. A big time saver. For those  of you who remember your Command line commands, it basically does a net use \\server /user:domain\user in a loop for each server you put in a list.

Print
Posted: Mar 16, 2018,
Categories: SharePoint & EPM,
Comments: 0,
Author: Urish Arora

Urish AroraUrish Arora

Other posts by Urish Arora

, Contact author

Please login or register to post comments.

Name:
Email:
Subject:
Message:
x

SEARCH

Categories

«October 2019»
MonTueWedThuFriSatSun
30123456
78910111213
14151617181920
21222324252627
28293031123
45678910

  • Featured Posts
  • Recent Posts
  • Recent Comments
Dynamics365Authority is a community platform for Professionals and Students to contribute or share their knowledge and skills on Microsoft Dynamics 365 Technologies. Our primary goal is to invite professionals on Dynamics 365 technology across the world to contribute & share their knowledge and skills through their blogs so that we can help other developers.
Stay updated with Dynamics 365 technology. Improve skills and knowledge from our blogs, articles and code snippets. Learn it. Follow professionals and learn from them.
Unified Service Desk Book(Online Edition) 

FOLLOW US

Stay connected with us on our social media channels for latest articles, blogs posts etc.  We will keep updating regularly on our social media platform and web platform.

FACEBOOK

Follow us on Facebook

 

TWITTER

View all our tweets

 

DYNAMICS365AUTH

Join us now

 

BLOGS

View our blogs

 

 

Latest Blog

Posted: Jun 20, 2019

Overview - Appendix (Unified Service Desk)

This blog is about Appendix

Read more
Posted: Jun 20, 2019

Overview - Troubleshoot and Debug (Unified Service Desk)

This blog is about Troubleshoot and Debug in Unified Service Desk

Read more
Posted: Jun 20, 2019

Overview - Performance (Unified Service Desk)

This blog is about the Performance in Unified Service Desk

Read more
RSS

ADDITIONAL RESOURCES

Dynamics 365 Authority.com - Search the library for "Dynamics 365"

  What's New in Dynamics 365

  Dynamics 365 Documentation

  

  Sign-up for 30 days trial

 

 

Recent comments

Ashish:

Nice blog. Very helpful to get all references to white papers at one place.

Previous Next

About Us

Here comes the Dynamics 365 Authority - Great technical blog posts are hidden gems. They are hard to find simply because not enough of us write them in the first place. Yet technical blogging is one of the best things we can do not only for ourselves, but also as members of the wider community of developers.

Dynamics 365 Authority leverages this platform to help developers and users to move from traditional paper-based process to modern digital business process. Dynamics365Authority.com helps your business grow, evolve and transform.

Dynamics365Authority.com is your Digital Transformation Partner

Recent Posts

Overview - Appendix (Unified Service Desk)

This blog is about Appendix
  • 216
  • Article rating: 5.0

Overview - Troubleshoot and Debug (Unified Service Desk)

This blog is about Troubleshoot and Debug in Unified Service Desk
  • 303
  • Article rating: 5.0
RSS

Follow Us

 

Tag cloud: Dynamics365Authority.com with Urish Arora; Dynamics365Authority.com; Sales; Leading community site on MS Dynamics 365; Dynamics 365 Authority; Service;Top CRM Blogs; Urish Arora - Australia's leading expert on Digital Transformation;  Digital Transformation; Field Service;Top Articles on MS Dynamics CRM Relationship Insights; Office 365 Security Compliance; Project Service; Microsoft Dynamics 365 for Sales; Relevance Search; Goal Metrics; Activities and Case; Sales Literature;Knowledge Management;

Terms Of UsePrivacy StatementCopyright 2019 by Dynamics365Authority
Back To Top