Tuesday, December 20, 2016

Add Links to Resources List in SharePoint Central Administration

The Resources list in SharePoint Central Administration site lets you to keep frequently accessed links to the home page. Say for e.g. To access User profile service application, you'll have to navigate through:
  • Central Administration >> Application Management 
  • Manage Service Applications >> Search and pick your user profile service Application
in some other cases, you'll find a difficulty in navigating To-And-Fro in SharePoint Central Administration. So, Resources list comes handy to manage this hassle. Just add your frequently accessed links to it! When you log into SharePoint Central Administration site, you'll see the Resources link list in right pane.
Consider Resources list as your Favorites or Bookmarks List!
sharepoint 2013 central admin resources list
To Add a link/remove links in resources list:
  • Click on "Resources" link from SharePoint Central Admin home page (or your can Click the gear icon and click Site Contents >>  Find the Resources list)
  • From here you can add or delete the link like any list item.
    sharepoint 2013 add link to resources list in central admin
This saves time and effort, especially if you have trouble finding service applications in Central Admin.

Populate Resources List using PowerShell:
Lets use PowerShell to add items to Resources list in SharePoint Central Administration site.
Add-PSSnapin Microsoft.SharePoint.Powershell -ErrorAction SilentlyContinue

#Get Central Administration Site
$CentralAdminUrl = Get-SPWebApplication -includecentraladministration | where {$_.IsAdministrationWebApplication} | Select -ExpandProperty URL

#Get Resources list from Central Admin
$List = (Get-SPWeb -identity $CentralAdminUrl).Lists["Resources"]

#Get Service Applications to add to Resources List
$ServiceApps = Get-SPServiceApplication | Where {($_.TypeName -eq "Excel Services Application") `
                                 -or ($_.TypeName -eq "Managed Metadata Service") `
                                 -or ($_.TypeName -eq "User Profile Service Application") `
                                 -or ($_.TypeName -eq "Search Service Application") `
                                 -or ($_.TypeName -eq "Business Data Connectivity Service Application") }

#Loop through and Add Links to Resources list
foreach ($App in $ServiceApps)
{
    $Item = $List.Items.Add()
    $Item["URL"] = "$($App.ManageLink.Url), $($App.DisplayName)"
    $Item.Update()
}

Write-Host "Service Application Links added to Resource List!" -f Green


You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.
*Sponsored


Thursday, December 15, 2016

How to Create SharePoint 2016 Farm using PowerShell

Creating SharePoint 2016 farm using PowerShell is almost as same as in its previous version. In SharePoint 2016 there is an additional parameter -LocalServerRole added as SharePoint 2016 introduced MinRoles.

Pre-Requisites:
  • SQL Server is already installed and ready to use.
  • You have created a Farm account for SharePoint 2016.
  • You have logged in to the server (Setup account) which has Administrator access on all SharePoint servers and DB_Creator, Security_Admin Server roles in SQL Server.

Step 1: Install SharePoint 2016 prerequisites and binaries to each server in your proposed SharePoint 2016 farm.
install sharepoint 2016 farm using powershell
On completing the installation, Uncheck "Run the SharePoint Products Configuration Wizard now" and close the wizard.
create new sharepoint 2016 farm with Powershell

Step 2: PowerShell Script to Create SharePoint 2016 Farm:
Save the below script as "Create-Farm.ps1" or something like that, change the configuration settings parameters as per your environment. Open SharePoint 2016 Management Shell as Administrator, and run the script. You'll see
"The local farm is not accessible. Cmdlets with FeatureDependencyId are not registered."  error for the first time, which is quite normal, since we have not created the Farm yet! proceed running the script.

#Configuration Settings 
$DatabaseServer = "SP16-SQL"
$ConfigDatabase = "Intranet_Farm_Config"
$AdminContentDB = "Intranet_Farm_Content_Admin"
$Passphrase = "2FJlsXghFsas5vdJJKEXXwWF"
$FarmAccountName = "Crescent\Sp2016admin"
$ServerRole="SingleServerFarm"

#Get the Farm Account Credentials
$FarmAccount = Get-Credential $FarmAccountName
$Passphrase = (ConvertTo-SecureString $Passphrase -AsPlainText -force)
  
#Create SharePoint Farm
Write-Host "Creating Configuration Database and Central Admin Content Database..."
New-SPConfigurationDatabase -DatabaseServer $DatabaseServer -DatabaseName $ConfigDatabase -AdministrationContentDatabaseName $AdminContentDB -Passphrase $Passphrase -FarmCredentials $FarmAccount -LocalServerRole $ServerRole

$Farm = Get-SPFarm -ErrorAction SilentlyContinue -ErrorVariable err  
if ($Farm -ne $null) 
{
Write-Host "Installing SharePoint Resources..."
Initialize-SPResourceSecurity
 
Write-Host "Installing Farm Services ..."
Install-SPService
 
Write-Host "Installing SharePoint Features..."
Install-SPFeature -AllExistingFeatures
 
Write-Host "Creating Central Administration..."              
New-SPCentralAdministration -Port 2016 -WindowsAuthProvider NTLM
  
Write-Host "Installing Help..."
Install-SPHelpCollection -All  
 
Write-Host "Installing Application Content..."
Install-SPApplicationContent
  
Write-Host "SharePoint 2016 Farm Created Successfully!"
} 
Once the script completed successfully, You'll see farm created successfully message. Here I've used "SingleServer" as MinRole. You can adjust it based on your requirement.

Add Additional Servers to the SharePoint 2016 Farm:
Once you are done with the creation of the SharePoint 2016 farm from first server, You can connect rest of the servers to the Farm either using SharePoint products configuration wizard or with PowerShell.

Open SharePoint products configuration wizard and choose "Connect to an existing server farm" and run through the wizard! Select the server MinRole as per your topology.
powershell script to create sharepoint 2016 farm

Join Additional Server to the SharePoint 2016 farm using PowerShell:
If you prefer PowerShell way to add an additional server to the farm, use this PowerShell script.  
$ServerRole="Application"
#"Custom","WebFrontEnd","Application","DistributedCache","SingleServerFarm","Search","ApplicationWithSearch","WebFrontEndWithDistributedCache"

Connect-SPConfigurationDatabase -DatabaseServer $DBServer -DatabaseName $DBName -PassPhrase $SecurePassPhrase -LocalServerRole $ServerRole
 
Write-Host "Installing SharePoint Resources..."
Initialize-SPResourceSecurity
 
Write-Host "Installing Farm Services ..."
Install-SPService
 
Write-Host "Installing SharePoint Features..."
Install-SPFeature -AllExistingFeatures
 
Write-Host "Installing Help..."
Install-SPHelpCollection -All  
 
Write-Host "Installing Application Content..."
Install-SPApplicationContent
  
Write-Host "Joined the Server to Farm Successfully!"
If you don't want the server to host Distributed cache, use the parameter: -SkipRegisterAsDistributedCacheHost and the end!
Related post: How to Create SharePoint 2013 farm using PowerShell

You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.
*Sponsored


Wednesday, December 14, 2016

Open this link on a Phone - QR Code Feature in SharePoint 2016

SharePoint 2016 introduces a new feature to open links on your phone or tablet using QR codes. Here is how this feature works:
  • Go to any of your SharePoint 2016 library such as document library. From the document's context menu, click on the tiny phone icon.
    QR Code Open this link on a phone Feature in SharePoint 2016
  • This takes you to a page with QR code generated for the document URL. By default, every document is assigned with a Unique QR code.Open documents with QR code in sharepoint 2016
  • From your phone, use QR reader app to read the QR code and navigate to the document URL. This makes easier to share documents on mobile devices.


You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.
*Sponsored


Thursday, December 8, 2016

How to Create State Service Application in SharePoint 2016

Lot of components like InfoPath Form services, Visio, Search Service, workflows, etc relies in State Service Application of SharePoint to store the application sessions. If its not configured already, you'd probably see error messages such as:

"The form cannot be rendered. This may be due to a misconfiguration of the Microsoft SharePoint Server State Service. For more information, contact your server administrator."

How to Create State Service application in SharePoint 2016?
State service application can't be created through new service application page. If you go to New dialog of Central Administration >> Manage Service Application page, you won't find it! here is how to create state service application in SharePoint 2016.
  • Go to Central Administration site >> Click on "Configuration Wizards" link from the bottom
  • In Configuration Wizards page >> click Launch the Farm Configuration Wizard link >> and then click "Start the Wizard".
    sharepoint 2013 configure state service application
  • On the services configuration page, under Services applications section, select the State Service check box (select any other service applications you may require) and click Next.
    create state service application sharepoint 2016 powershell
  • Click on Skip button if you set-up a top-level site collection. If not, go ahead and create it now by clicking OK.
You can verify the new state service application by: going to Central Administration > Application Management > Manage service applications >> State service application should be listed there!
create state service application sharepoint 2016
Once you created state service application, make sure your new state service application is associated with your web application by going to Central Administration >> Manage Web Applications >> Select your web application >> Click on "Service Application Associations" from the ribbon >> and in "Configure Service Application Associations" page, State Services should be selected.

Disadvantage: Configuration wizard creates state service database with GUIDs! E.g. StateService_2349fb4359fb45c9a5255562cb0eab0b. So, to avoid GUIDs in database, Create State service application using PowerShell:

SharePoint 2016: Create State Service Application using PowerShell
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

#Configuration variables
$ServiceAppName = "State Service Application" 
$ServiceAppProxyName ="State Service Application"
$DatabaseName ="SP16_State_Service"

#Create New State Service application
$StateServiceApp = New-SPStateServiceApplication -Name $ServiceAppName 

#Create Database for State Service App
$Database = New-SPStateServiceDatabase -Name $DatabaseName -ServiceApplication $StateServiceApp  

#Create Proxy for State Service
New-SPStateServiceApplicationProxy -Name $ServiceAppProxyName -ServiceApplication $StateServiceApp -DefaultProxyGroup  

Initialize-SPStateServiceDatabase -Identity $Database

Write-host "State Service Application Created Successfully!"


You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.
*Sponsored


Tuesday, December 6, 2016

Configure My Sites in SharePoint 2016 - Step by Step Guide

SharePoint 2013 & SharePoint 2016 brought new social networking capabilities to the SharePoint collaboration space. With My Sites users can store documents, keep-up their profile information, news feed, contribute to the organization via blogs, follow activities on sites, people, tags, documents, etc! In short: My Site is the personal space for individual users in an organization. At high level, configuring my sites in SharePoint 2016 involves following steps:
  1. Create a dedicated web application & My Site host site collection
  2. Add a wildcard inclusion managed path to the web application
  3. Enable self-service site creation for the web application
  4. Create a permission policy & Grant everyone permission to My Site web application
  5. Configure My Site settings for the User Profile service application
This article walks you through step by step on creating and configuring My Sites for SharePoint 2016. Although this article aims at SharePoint 2016, same steps are applicable to SharePoint 2013 as well.

Prerequisites:
Before you create My Sites in SharePoint, you need to have the following services properly configured.
  • User Profile Service application - SharePoint My Sites depends on UPS! User Profile Service Application will be used to map the My Sites with the User Profiles.
  • Managed Metadata service application -  My Site users Keywords! so have MMS created  & configured prior setting up My Sites.
  • Search service application - not mandatory, but best practice for people search results!
Also make sure User Profile Service Application, Managed Metadata Service, and Search Service Application are up running and they are connected to your My site web application through service connections in Central Admin.

Step 1: Create New web application for My Sites

Although you can use an existing web application, its a best practice to create a dedicated web application for My sites for reasons like security, performance, etc. So, To start with, lets create a dedicated web application to host our my sites in SharePoint 2016.
  • Open SharePoint 2016 Central Administration site.
  • From Application Management >> Click the Manage Web Applications >> Click New to Create New Web Application.
  • Provide a Name, Port, Host Header, and fill the rest of the new web application form. Hit OK to create new web application.
create my site host sharepoint 2013

Create My Site Host Site Collection in SharePoint 2016:
Once the web application is created, proceed with creating a site collection in the root of the web application.
  • From SharePoint 2016 Central Administration, select Application Management and then select Create site collections
  • Select the Web application we created in the previous step. 
  • Provide a name and description to the site collection.
  • Choose the "My Site Host" as template.
  • Provide a primary site collection administrator.
  • Leave the quota option default.
  • Click the OK button to create the site collection.
create my site host sharepoint 2016

Step 2: Add new managed path to the My Site Web Application:

Managed paths defines the location to host site collections within a web application. In our environment, When SharePoint users provision their My Sites, we would like them to reside at http://mysite.crescent.com/personal/name-of-person/. So, We defined a wildcard managed path for "/personal/" as follows:
  • From SharePoint Central Administration >> Manage Web Application >> Select the My Site Host Web Application you just created.
  • In the ribbon click the Managed Paths button >> Define Managed Paths dialog, Add a new path called "personal" (or "my" or whatever you like!) and make it Wildcard inclusion. Click "Add Path" and then OK once done.
  • Optionally, You can delete the OOTB "Sites" managed path from My site web application.
    sharepoint mysite configuration

Step 3: Enable self-service site creation for the web application

Self-service site creation option enables the end user to create their own My site collection automatically.
  • Select your web application from Manage Web Applications page of Central Administration site.
  • Click on "Self Service Site Creation" button for the web application
    configure my site sharepoint 2013
  • Select "On" for Site Collections and "Prompt users to create a team site" under Start a Site. Provide the managed path we created ("/personal"). Leave the rest default.
    sharepoint 2013 my site step by step

Step 4: Add Permission Level Policy & User Permission to My Site Web Application (Optional):

Perform this step only when you want your users to create subsites under my site site collection. Create a permission level policy with "Create Subsites" rights.
  • Select your My Site web application and Click on the "Permission Policy" button from the ribbon. In the "Manage Permission Policy Levels", click on "Add Permission Policy Level" link.
    sharepoint 2016 mysite web application
  • Under Permissions, scroll to Site Permissions, select the Grant option for "Create Subsites - Create subsites such as team sites, Meeting Workspace sites, and Document Workspace sites". Now, the new permission policy level should appear among other policy levels.
    sharepoint 2016 my sites configuration
  • You need to grant that policy level to all users. Highlight your my site web application, Click on the "User Policy" button from the ribbon.
  • Click on "Add users" link >> Choose All zones and enter the users as "Everyone". Click OK to commit your changes.
    sharepoint 2013 my site creation

Step 5: Configure My Site URL in the User Profile Service Application

Alright, Now you have a My Site Web Application, My Site Host root site collection,  wildcard managed path and self-service enabled for the web application. The only remaining thing would be to set up My Site URL on User Profile Service Application, So that user profile service knows where to create new site collections for user My Sites. 
  • Go to Central Administration >> Application Management >> Manage service applications.
  • Select your User Profile Service Application >> On the Manage User profile service page, in My Site Settings section, click on "Setup My Sites" link.
    sharepoint 2013 my site step by step
  • Enter the My Site Host URL and click Save.
  • Specify other settings like Personal Site Location, Site Naming Format, Secondary Owner, etc.
Each My Site exists as a separate site collection to provide security isolation in SharePoint.

Optional: Set up interval for activity feed timer job
  • Go to the Central Administration >> Monitoring >> Timer Job >> Review job definitions
  • Find "User Profile Service Application - Activity Feed Job", and set up the activity feed sync time according to your needs. By default, its set to run for every 10 Minutes.

Create My Sites in SharePoint 2016:
So, we completed all configurations to get My sites up and running. Lets perform a quick test.
  • Go to any of the SharePoint site in the farm and select "About Me" link from the welcome menu.
  • You will redirected to your personal My Site home page if all fine, Where you can edit Your personal details like profile picture, contact information etc.
    sharepoint my site configuration
My Site Quota & Content Database sizing - Best Practices:
Setup Storage Quota for My Sites! By default, this setting is unlimited. - But you don't want your SQL disks get filled by My Sites, isn't it?

By default, The maximum number of site collections created per content database is 5000. If you are planning for 10,000 My Sites, of 100 GB each you'll need 1000 TB disk space! So, plan to adhere Content database sizing recommendation - 200 GB or less per content database for better performance.

Technet reference: Configure My Sites in SharePoint Server 2016


You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.
*Sponsored


Friday, December 2, 2016

Shared MinRoles in SharePoint 2016 Feature Pack 1

MinRole was an exciting new feature introduced in SharePoint 2016. In Simple words, based on the MinRole you select during setting up your Farm, SharePoint 2016 automatically takes care of services to run on that server and optimizes it to delivers better performance and reliability. However, the downside is: You need Eight SharePoint servers to have an highly available SharePoint 2016 farm!

So now with Feature pack 1, You can combine Web Front End and Distributed Cache roles - Application and Search roles together! and you just need Four servers to have a highly available SharePoint 2016 farm instead of Eight! Apart from MinRoles enhancement, Feature pack 1 also brings features such as: Central Administration Administrative Actions Logging, Custom Tiles in the SharePoint app launcher, Hybrid Auditing, Hybrid Taxonomy, OneDrive API, etc.

If you have installed Feature pack 1 prior creating SharePoint 2016 farm, this how it looks like on farm creation wizard:
Shared MinRoles in SharePoint 2016 Feature Pack 1
If your SharePoint farm is already created, you can switch the MinRoles from SharePoint 2016 Central Administration site: How to switch Server's MinRole in SharePoint 2016

How to Install Feature Pack 1 in SharePoint 2016?
Download and install November 2016 CU which brings the Feature pack 1 for SharePoint 2016. In addition, If you have language packs installed in your farm, you need to download and install the November 2016 CU Language pack fix (Optionally, you can download and install all other updates from Technet - SharePoint 2016 Updates ,
Don't forget to run SharePoint products configuration wizard once After the installation!


You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.
*Sponsored


Tuesday, November 15, 2016

Fix for "Cannot Connect to Database Master at SQL Server at Server Name - The Database might not exist, or the current user does not have permission to connect to it" SharePoint Error

Problem:
When trying to create a new SharePoint farm using PowerShell, the SharePoint 2016 management Shell gave an error message:
New-SPConfigurationDatabase : Cannot connect to database master at SQL server at <SQL-Server-Alias>. The database might not exist, or the current user does not have permission to connect to it.
New-SPConfigurationDatabase : Cannot connect to database master at SQL server at SP16_SQL. The database might not exist, or the current user does not have permission to connect to it.
Tried using SharePoint products configuration wizard as well and got the same issue!

Troubleshooting Checklist:
  1. Check the permissions for the Setup account which you are using to run the wizard or PowerShell. Make sure the setup account is granted with "DB_Creator" and "Security_Admin" Server Roles.
  2. In case of Named instance, it should be "Server\InstanceName". If is is SQL Alias, make sure the alias is properly configured and should be accessible from SharePoint Server. Verify if the SQL Server Alias is created for both 32 and 64-bit! How to Create SQL Server Alias for SharePoint
  3. Check if the SQL Server Service is running on your Database Server. Verify "TCP/IP" protocol is enabled under Network Configuration section of SQL Server Configuration Manager. 
  4. Test the connectivity between SharePoint and SQL Server. Try adding a HOST file entry in your SharePoint Server to point the SQL Server's IP!
  5. Check the firewall rules on SQL Server. If firewall is enabled on SQL Server, Create inbound TCP rule with ports: 1433,2383,2382. and inbound UPD rule with port: 1434.
  6. Double check if you have not fat-fingered User Name or Password!


You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.
*Sponsored


Tuesday, November 8, 2016

How to Create New Target Application ID in Secure Store Service for BCS in SharePoint 2016

When you want to consume external data in SharePoint, such as data from your other business applications, you can use Business Connectivity Services (BCS) together with Secure Store Service. The external data source that you can connect to is called a Secure Store Target Application. BCS makes it possible for you to set up a connection to the Target Application, and the Secure Store enables you to manage the credentials that are required by the external data source

Before proceeding, You have created and configured Secure store service application and generated the master key from SharePoint 2013/2016 Central Administration site, isn't it? If not, Refer:
Now you are all set to create new Target Applications and use in SharePoint. Here you go!

How to Create New Target Application ID?
Here are the steps to Add new Target Application ID in SharePoint 2016 Secure store Service:
  • Go to SharePoint Central Administration site >> Click on "Manage Service Applications"
  • Locate and pick your Secure store service application
  • In the Ribbon, Under the Edit tab click on New button
  • Enter the Target Application ID (Make sure the ID is unique - and you can't change it later), Display Name, Contact E-Mail. Choose the application type - Group: Maps group of users to a single set of stored credentials Individual: Maps a single user to a single set of stored credentials. Click Next.
    sharepoint secure store application id
  • The next window gives you the ability to Add/Change credential fields associated with the external data source. In my case, I left it with Windows User Name and Windows Password fields as they are sufficient to connect with SQL Server database using windows credentials. Click on Next.
    If you want to use SQL authentication , Select "User Name" and "Password" in Field type dropdown
    sharepoint secure store application id 2013
  • Enter the name(s) of the users that will administer the target application and Group who will use the target application and click OK
    sharepoint 2013 secure store target application type
Now we have successfully created target application.  

Set up Credentials for New Target Application ID:
The next step is to set the credentials for the target application ID.
  • Click on Context menu of newly created Target Application Id and choose Set Credential
    sharepoint 2016 create secure store application id
  • Enter the User Name and Password & Confirm Password which will be used to connect to the target data source on behalf of authorized users and click on OK to complete the creation of secure store target application ID. Make sure this access account (In my case its: Crescent\DBAccess) have proper rights on external database for the operation such as Read/Write.
    sharepoint designer secure store application id
Now All users of the given group can use the Application ID to connect with external data source with the application ID generated! Once the target application is created in Secure store service, you can associate it with any application to interact with the external database or application model, such as from SharePoint Designer, Excel, etc.

You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.
*Sponsored


Thursday, October 27, 2016

Copy Permissions from One SharePoint Site to Another using PowerShell

Requirement: Copy permissions from one site to another in SharePoint!

Solution: If you want to copy one SharePoint site to another site, there is no OOTB ways! However, You can use PowerShell to copy permissions between sites. Here is my PowerShell script to copy site permissions.

Copy Permissions from one site to another using PowerShell:
Add-PSSnapin Microsoft.SharePoint.PowerShell -erroraction SilentlyContinue
 
#PowerShell Function to copy permissions from one site to another
Function Copy-SitePermissions()
{
 param(
     $SourceWebURL,
     $TargetWebURL
 )
 Try {
  #Set the Error Action
    $ErrorActionPreference = "Stop"
  
  #Get the Source and Target Webs
  $SourceWeb = Get-SPWeb $SourceWebURL
  $TargetWeb = Get-SPWeb $TargetWebURL
  
  #if permissions are Inherited in the target, Break it!
  if($TargetWeb.Permissions.Inherited)
  {
   #Reset the Inheritence in Target Web
   $TargetWeb.BreakRoleInheritance($false)
  }
   #Copy permissions from Source to Target Web
     $SourceWeb.RoleAssignments | foreach-object {
     $TargetWeb.RoleAssignments.Add($_)
     }
    $TargetWeb.Update()
    Write-Host "Permissions copied from Source Site to the Target!" -f Green
 }
 catch {
   Write-Host $_.Exception.Message -ForegroundColor Red
 }
 finally {
  #Reset the Error Action to Default
  $ErrorActionPreference = "Continue"
 }
}

#Call the function to copy Web permissions 
Copy-SitePermissions -SourceWebURL "http://portal.crescent.com/ProjectHub/" -TargetWebURL "http://portal.crescent.com/TaxAudits/" 


You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.
*Sponsored


Sunday, October 23, 2016

Customize Suitebar Text and Link in SharePoint 2016 using PowerShell

Requirement:
By default, SharePoint 2016 comes with "SharePoint" as the suitebar branding text.  What if you would like to change it to something meaningful, say "Your Company Intranet"? Well, PowerShell can help to customize the branding text, Logo and URL in SharePoint 2016.
sharepoint 2016 add link to suite bar powershell
PowerShell Script to change Suitebar navigation text and link:
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

$WebApp= Get-SPWebApplication "http://intranet.crescent.com"
$WebApp.SuiteNavBrandingText = "Crescent Portal"

#Blank image from Layouts folder
$webapp.SuiteNavBrandingLogoUrl = "/_layouts/images/dot_ruleper.gif"
$webapp.SuiteNavBrandingLogoTitle = "Crescent Logo"
$webapp.SuiteNavBrandingLogoNavigationUrl = "http://portal.crescent.com"
$webapp.Update()

Here is the result of customized SharePoint 2016 suite bar branding using PowerShell!
customizing the sharepoint 2016 suite bar branding using powershell
My another post Customizing the SharePoint 2013 suite bar branding using PowerShell

You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.
*Sponsored


Saturday, October 22, 2016

How to Delete a SharePoint Web Application

SharePoint Web Applications are actually an IIS Containers at top level. Each web application we create from SharePoint, creates respective site in IIS and a content database in SQL Server.

To delete a SharePoint 2016 Web Application,
  • Open SharePoint 2016 Central Administration Site
  • Click on "Manage web applications" link under "Application Management"
  • Select your target web application, and from the ribbon, click on Delete button.
    how to delete a web application in sharepoint 2013
  • Specify whether you would like to delete the content databases and IIS web sites.
    how to delete a sharepoint web application
  • Confirm the Prompt once to delete a web application in SharePoint 2013 and your web application will be deleted momentarily.
This removes the specified web application from the SharePoint farm.

SharePoint delete web application zone:
To delete SharePoint web application extension, From SharePoint Central Administration:
  • Click on Administration Management >> Manage Web Applications
  • Select the web application you wish to remove the extended zone from >> Click on Delete button drop-down and choose "Remove SharePoint from IIS Web Site"
  • Select IIS web site & zone to remove, (make sure its not your "Default" zone!)
  • Set the value for "Delete IIS web sites" to "Yes" and click OK to delete web application zone.
    sharepoint delete web application zone
To delete a SharePoint web application using PowerShell, use this script: Delete SharePoint web application using PowerShell

You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.
*Sponsored


Monday, October 10, 2016

Add-Remove User to SharePoint Multi-Valued People Picker Field using PowerShell

Requirement: 
We've a SharePoint list called "Projects" with 1000's of items. The list has a field called "Team Members" which allows multiple user values. We often get a requirement to either add or remove a particular user to all items or specific items filtered by other columns in the list.

Solution: Adding-removing user from multiple items in a bulk can be achieved with PowerShell. Lets use PowerShell to add or remove user from SharePoint people picker (person or group) field value.
powershell to add remove user to people picker column value in sharepoint


PowerShell to Add new user to Person or Group Field:
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
 
#Configuration parameters
$SiteURL = "http://portal.crescent.com/projects/"
$ListName = "Projects"                
$FieldName= "TeamMembers"
$UserToAdd="Crescent\Sam"

#Get site and List objects
$web = Get-SPWeb $SiteURL
$List = $web.Lists.TryGetList($ListName)

#Item Ids to update
$IDColl= @(4,5,7,14,55,169,258,260,261)

#Iterate through each item
foreach($ItemID in $IDColl)
{
    #Get the Item
    $Item = $List.GetItembyID($ItemID)
 Write-Host "Processing: "$item["ProjectName"]
    
    #Get Existing field value
    $MultiUserCollection = [Microsoft.SharePoint.SPFieldUserValueCollection]$item[$FieldName]
          
    #Prepre the user to Add
    $User = $Web.EnsureUser($UserToAdd)

 #Add new user to the collection
 $NewUser = new-object Microsoft.SharePoint.SPFieldUserValue($Web, $User.ID,$User.Name)
 $MultiUserCollection.Add($NewUser)

 #Update the field value
 $item[$FieldName] = $MultiUserCollection
 $item.update()   
 
 write-host "Team Member Added!"     
}

PowerShell to remove user from Multi-user People Picker field:
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
 
#Configuration parameters
$SiteURL = "http://portal.crescent.com/projects/"
$ListName = "Projects"                
$FieldName= "TeamMembers"
$UserToRemove="Crescent\Sam"

#Get site and List objects
$web = Get-SPWeb $SiteURL
$List = $web.Lists.TryGetList($ListName)

$IDColl= @(184,259,281,282,306,318,331,378,404,410)
foreach($ItemID in $IDColl)
{
        #Get the Item
        $Item = $List.GetItembyID($ItemID)
        Write-Host "Processing: "$item["ProjectName"]
        
        #Get Existing field value
        $MultiUserCollection = [Microsoft.SharePoint.SPFieldUserValueCollection]$item[$FieldName]
        $NewUserCollection = new-object Microsoft.SharePoint.SPFieldUserValueCollection
       
        #Prepre the user to remove
        $User = $Web.EnsureUser($UserToRemove)
  
        #Create a new collection - exclude user to remove      
        Foreach($MultiUser in $MultiUserCollection)
        {
            if($MultiUser.User.LoginName -ne $User.LoginName)
            {
                #Add user to new collection
                $NewUser = new-object Microsoft.SharePoint.SPFieldUserValue($Web, $MultiUser.User.ID,$MultiUser.User.Name)
                $NewUserCollection.Add($NewUser)
            }
         }
        #Update the list item 
        $item[$FieldName] = $NewUserCollection
        $item.update()   
  
        write-host "User Removed From Existing People Picker field Value!"     
 }


You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.
*Sponsored


Monday, October 3, 2016

Update SharePoint List Items from CSV File using PowerShell

Requirement: Update SharePoint List Items from CSV file.

Bit background: We've a list with 1000's of rows of organization wide experts. Later we added a new field for "Department". Now the requirement is to update Department field for specific list of users. While the datasheet view can be used for bulk editing, filtering and editing 100's of rows would be time consuming. So the solution is: Have list of user names and their departments in CSV file format, give it to PowerShell!

PowerShell Script to Read from CSV file and Update SharePoint List Items:
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
 
#Read the CSV file
$CSVData = Import-CSV -path "C:\UserData.csv" 
 
#Get the Web
$web = Get-SPWeb -identity "http://portal.crescent.com"
 
#Get the Target List
$List = $web.Lists["ExpertProfiles"]
 
#Iterate through each Row in the CSV
foreach ($Row in $CSVData) 
{
    #Get the List Item matching "Name" field in the CSV    
    $Item = $List.Items | Where-Object { $_["Title"] -eq $Row.Name }

    if($item -ne $null)
    {
 #Update List Item - Internal Name!
        $item["Department"] = $row.Department
        $item.Update()
        Write-Host "Updated:"$row.Name -ForegroundColor Green
    }
    else
    {
        write-host "No matching Item Found for:"$row.Name -f Red
    }
}
While the above code serves the purpose, Lets optimize it with CAML-SPQuery

PowerShell to Update SharePoint List from CSV:
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
 
#Read the CSV file
$CSVData = Import-CSV -path "C:\UserData.csv" 
 
#Get the Web
$web = Get-SPWeb -identity "http://portal.crescent.com"
 
#Get the Target List
$List = $web.Lists["ExpertProfiles"]
 
#Iterate through each Row in the CSV
foreach ($Row in $CSVData) 
{
    #Filter using CAML Query
    $CAMLQuery="<Where><Eq><FieldRef Name='Title'/><Value Type='Text'>$($Row.Name)</Value></Eq></Where>"
    $SPQuery=New-Object Microsoft.SharePoint.SPQuery
    $SPQuery.ViewAttributes = "Scope='Recursive'"  #Get all items including Items in Sub-Folders!
    $SPQuery.Query=$CAMLQuery
    $SPQuery.RowLimit = 1 
     
    #Get the List item based on Filter 
    $Item=$List.GetItems($SPQuery)[0]

    If($Item -ne $null)
    {
        #Update List Item
        $Item["Department"] = $Row.Department
        #$item.Update()
        Write-Host "Updated:"$row.Name -ForegroundColor Green
    }
    else
    {
        write-host "No matching Item Found for:"$row.Name -f Red
    }
}
Update People Picker Field Value from CSV file:
In an another case, I had to update people picker field value:
 #If the matching project found
    If($Item -ne $null)
    {
        #Update Team members Multi-People picker field
  $TeamMembersList = new-object Microsoft.SharePoint.SPFieldUserValueCollection
  $TeamMembers = $row."TeamMembers" -split ';'
  foreach ($TeamMember in $TeamMembers)
  {
   if ($TeamMember -ne $null) 
   {
    #Prepre the user to add
       $User = $Web.EnsureUser($TeamMember)
       $NewUser = new-object Microsoft.SharePoint.SPFieldUserValue($Web, $User.ID, $User.LoginName)
    $TeamMembersList.Add($NewUser)
   }
  }
  #Update Team members field
  $item["Team Members"] = $TeamMembersList
  $item.Update()
        Write-Host "Updated:"$Row.ProjectName -ForegroundColor Green
    }
    else
    {
        write-host "No matching Item Found for:"$row.ProjectName -f Red
    } 

Related Posts:


You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.
*Sponsored


Thursday, September 15, 2016

An error occurred while getting information about the user at server : The RPC server is unavailable

Problem:
After installing SharePoint 2016 to setup a new farm, tried running SharePoint 2016 products configuration wizard, and the wizard failed at step 3 saying:
Failed to create the configuration database.
An Exception of type System.InvalidOperationException was thrown. An error occurred while getting information about the user <Farm-Admin> at server <Domain-Name>: The RPC server is unavailable
Failed to create the configuration database. Additional exception information: An error occurred while getting information about the user account at server domain: The RPC server is unavailable
Tried creating SharePoint farm using PowerShell, but got the same results.

Troubleshooting:
  • Verified that the SharePoint server is part of the domain and there is no connectivity, network, firewall related issues.
  • Verified that the setup account is granted with DB_Creator & Security_Admin server roles. 
  • Tried Adding the IP of the DC to HOST file of the Local server
  • Tried ipconfig /flushdns - and ipconfig /registerdns commands as per Technet forums, but didn't help!
Solution: Download and install the KB KB3115299 to fix this issue!

As a general recommendation, download and install all latest patches before you create SharePoint 2016 farm. Download latest patches from Microsoft Technet site:
https://technet.microsoft.com/en-us/library/mt715807(v=office.16).aspx#BKMK_2016



You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.
*Sponsored


Tuesday, September 6, 2016

How to Change Default Content Access (Crawl) Account in SharePoint 2016 Search

Once we complete creating Search Service Application, The next step is to configure default content access account, which is used by Crawl Component to crawl the content sources like SharePoint content. This crawl account will have read access to all your search content sources such as SharePoint Web Applications.

You can change search crawl account from SharePoint Central Administration as:
  • SharePoint Central Admin >> Application Management >> Manage Service applications
  • From the service applications list, Select the Search service application
  • In the Search Administration page, click on the account already configured for Default content access account.
  • Provide the new crawl account user name and password.
    How to Change Default Content Access Crawl Account in SharePoint 2016 Search

PowerShell to Change Search Crawl Account in SharePoint 2016:
If you want to change the default content access account for SharePoint 2013 search service application using PowerShell, use this script:

Add-PSSnapin Microsoft.SharePoint.Powershell -ErrorAction SilentlyContinue

#Set Default content access account
$AccountID = "Crescent\SP16_Crawl"
$Password = Read-Host -AsSecureString  

#Get Search service application
$SearchInstance = Get-SPEnterpriseSearchServiceApplication

#Set default content access account for crawl
Set-SPEnterpriseSearchServiceApplication -Identity $SearchInstance -DefaultContentAccessAccountName $AccountID -DefaultContentAccessAccountPassword $Password
As soon as you change Search Crawling Account, SharePoint automatically creates a web application policy with "Full Read" permissions on all Web applications!

You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.
*Sponsored


How to Test Outgoing Emails in SharePoint using PowerShell?

On troubleshooting SharePoint Email issues, as a first step, we have to check outgoing Email settings applied on SharePoint central Administration site are valid. So, how to test SharePoint outgoing email quickly? Here are my PowerShell scripts to test outgoing email in SharePoint 2013.

Method 1: Send Email using SPUtility's SendEmail
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

#Configuration Parameters
$SiteURL="http://portal.crescent.com/ "
$Email = "salaudeen.rajack@crescent.com"
$Subject = "Test Email from SharePoint"
$Body = "Test Email Body"

#Get the Web 
$Web = Get-SPWeb $SiteURL

#Send Email using SPUtility SendEmail method
[Microsoft.SharePoint.Utilities.SPUtility]::SendEmail($Web ,0,0,$Email,$Subject,$Body)
The above PowerShell script sends Email to the given Email and returns "true" if success.
how to test sharepoint outgoing email

Method 2: Using .Net SMTP Send Mail
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

#Parameters
$EmailTo = "salaudeen.rajack@crescent.com"
$Subject = "Test Email from SharePoint"
$Body = "Test Email Body"

#Get the outgoing Email Server settings
$SPGlobalAdmin = New-Object Microsoft.SharePoint.Administration.SPGlobalAdmin
$SMTPServer = $SPGlobalAdmin.OutboundSmtpServer
$EmailFrom = $SPGlobalAdmin.MailFromAddress

#Frame Email Message
$Message = new-object Net.Mail.MailMessage
$SMTP = new-object Net.Mail.SmtpClient($SMTPServer)
$Message.From = $EmailFrom
$Message.To.Add($EmailTo)
$Message.subject = $Subject
$Message.body = $Body

#Send the Email
$SMTP.Send($Message)

Method 3: Using PowerShell 3.0 Send-Mail Message
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

#Parameters
$EmailTo = "salaudeen.rajack@crescent.com"
$EmailSubject = "Test Email from SharePoint"
$EmailBody = "Test Email Body"

#Get the outgoing Email Server settings
$SPGlobalAdmin = New-Object Microsoft.SharePoint.Administration.SPGlobalAdmin
$SMTPServer = $SPGlobalAdmin.OutboundSmtpServer
$EmailFrom = $SPGlobalAdmin.MailFromAddress

#Using PowerShell 3.0 Send-Mail Message:
Send-MailMessage -To $EmailTo -From $EmailFrom -Subject $EmailSubject -Body $EmailBody -BodyAsHtml -SmtpServer $SmtpServer -UseSsl
Last but not least, We may have to make sure exchange server or SMTP accepts Emails from SharePoint servers

You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.
*Sponsored


Change My Site Host URL in User Profile Service Application using PowerShell

Once My site host web application and site collection is created, the next step is to configure user profile service application to use the My site host. Here is how to set my site host in user profile service application of SharePoint 2016.
  • Login to SharePoint 2016 Central Administration site
  • Click on Application Management >> Manage service applications.
  • Select your User Profile Service Application >> From the Manage User profile service page, under My Site Settings section, click on "Setup My Sites" link.
    sharepoint 2016 set my site host url powershell
  • Enter the My Site Host URL and click Save. You may have to specify other settings such as Personal Site Location, Site Naming Format, Secondary Owner, etc.
Make sure your My Site URL is the default one under AAM!

PowerShell to Set My Site Host Location in SharePoint: 
Lets change my site host URL in SharePoint 2013 using PowerShell
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

$MySiteHostURL="http://mysite.crescent.com/ "

#$MySite = Get-SPSite $MySiteHostURL
$SiteContext = Get-SPServiceContext($MySiteHostURL)
$UPM = new-object Microsoft.Office.Server.UserProfiles.UserProfileManager($SiteContext)
#remove my site host location
$UPM.MySiteHostUrl = ""
#Change My Site Host location
$UPM.MySiteHostUrl = $MySiteHostURL
Write-host "My Site Host Location Changed!"

Tags: sharepoint change my site host url, sharepoint 2010 change my site host url powershell, sharepoint 2013 change my site host, sharepoint 2013 change my site host location, change my site host url sharepoint 2013 powershell, sharepoint 2013 my site host url

You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.
*Sponsored


Create My Site Host Site Collection for SharePoint 2016 using PowerShell

PowerShell script to create Web application and My site Host Site Collection for SharePoint 2016:

Step 1: Create a Web application for My Site:
#PowerShell to create a web application
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

#Define Variables for Web Application Creation
$WebAppName = "Crescent Mysite"
$HostHeader = "mysite.Crescent.com"
$WebAppURL="http://" + $HostHeader
$WebAppPort = "80"
$ContentDBName = "Crescent_MySite_Content"
$AppPoolName = "MySite Web Application AppPool"
$AppPoolAccount = "Crescent\SP16_AppPool"

#Authentication Provider
$AuthProvider = New-SPAuthenticationProvider 

#Check if Managed account is registered already
Write-Host -ForegroundColor Yellow "Checking if the Managed Accounts already exists"
$AppPoolAccount = Get-SPManagedAccount -Identity $AppPoolAccount -ErrorAction SilentlyContinue
if($AppPoolAccount -eq $null)
{
    Write-Host "Please Enter the password for the App Pool Account..."
    $AppPoolCredentials = Get-Credential $AppPoolAccount
    $AppPoolAccount = New-SPManagedAccount -Credential $AppPoolCredentials
}

#Create new Web Application
New-SPWebApplication -name $WebAppName -port $WebAppPort -hostheader $HostHeader -URL $WebAppURL -ApplicationPool $AppPoolName -ApplicationPoolAccount (Get-SPManagedAccount $AppPoolAccount) -AuthenticationMethod NTLM -AuthenticationProvider $AuthProvider -DatabaseName $ContentDBName

Step 2: Create "Personal" Managed Path:
#Create Managed Path for My Site Web application
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

#Define Parameters 
$WebAppURL = "http://mysite.Crescent.com"
$WebApp = Get-SPWebApplication $WebAppURL

#Add Managed Path
New-SPManagedPath "Personal" -WebApplication $WebAppURL -Explicit 


Step 3: Enable Self Service Site Creation for My Site Web Application:
#Enable Self service site creation
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

#Set Parameters 
$WebAppURL = "http://mysite.Crescent.com"
$WebApp = Get-SPWebApplication $WebAppURL

#Enable Self Service Site collection
$webApp.SelfServiceSiteCreationEnabled = $true
$webApp.RequireContactForSelfServiceSiteCreation = $false
$webApp.Update()


Step 4: Create My Site Host Site Collection:
#Create My Site Host Site collection
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

#Set Parameters for My Site Host Site Collection Creation
$WebAppURL = "http://mysite.Crescent.com"
$FarmAdminAccount="Crescent\SP16_Farm"
$Contentdatabase="Crescent_MySite_Content"
$WebApp = Get-SPWebApplication $WebAppURL

#Create My Site Host site collection
New-SPSite -Name "My Site Host" -Url $WebAppURL -Template "SPSMSITEHOST#0" -OwnerAlias $FarmAdminAccount -ContentDatabase $Contentdatabase
Once all these steps are completed, make sure you set My Site Host location in your user profile service application!

You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.
*Sponsored


Sunday, September 4, 2016

How to Hide the Timeline in the Task List of SharePoint 2013/2016

Requirement: Hide timeline from SharePoint 2016 task list
sharepoint task list hide timeline
Solution: Here is how you can hide the timeline in SharePoint 2013/2016 task lists.
  1. Go to the Task List, Click on List Tab and then click on "Modify View" button from the ribbon.
  2. In the Edit view page, scroll down and expand the 'Style' section.
  3. Under the Style selection, Uncheck the checkbox 'Show timeline above the view'
  4. click on 'OK' button to save changes.
Here is the Result:
sharepoint 2013 task list hide timeline

Alternatively, You can edit the page, Edit List view properties, and uncheck "Show Timeline" Checkbox to hide timeline from SharePoint tasks list.

You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.
*Sponsored


Thursday, September 1, 2016

Backup-Restore All SharePoint Databases in SQL Server using PowerShell

Requirement: We planned to move our SharePoint's SQL database to a different server. So, we had to backup and restore all SharePoint databases from one SQL Server 2012 instance to another.

Solution:
Here are the steps at high level to move SharePoint from one SQL Server to another:
  1. Get a list of all SharePoint databases
  2. Backup all SharePoint databases from the source SQL Server
  3. Restore the backups to the target SQL server instance
  4. Change the SQL Alias in SharePoint Server to point to the new server.
Step 1: Get all SharePoint databases
#Get All SharePoint Databases and form an Array
Get-SPDatabase | Select -ExpandProperty Name | foreach { $Databases+= $_+"," }

#Export to a txt file
$Databases > databases.txt
This script gets you a list of all SharePoint databases, including configuration database, content databases and service application databases to a comma separated string. Lets take that string and give it to our backup script.
Tips: If you want to get all Content databases, use: Get-SPContentDatabase | Select -Expandproperty Name

Step 2: Backup All SharePoint Databases:
Before taking backup of all SharePoint databases, make sure you set the site(s) to Read-only mode (or set the database to Read-only in SQL Server) in order to avoid any data inconsistency issues.

Here is the PowerShell script to backup all Databases from SQL Server:
#Import SQL PowerShell module
Import-Module SQLPS –DisableNameChecking

#Configuration parameters
$SQLInstance="Cre-SQL-001"
$BackupPath="F:\Backup\"

#Array of Database names, Comma separated
$DatabaseColl="StateService_d73ac2ad313a41ba83d457bfb78cb4f3,Secure_Store_Service_DB_c13a71870bad4decb6f7582d9e26f46a,WordAutomationServices_e290fc12c8ee4ce09c38ba7fc8f089c9,Social DB,Bdc_Service_DB_f937be05fe5f48158d4895b6f2bb9674,WebAnalyticsServiceApplication_StagingDB_9efa01f9-ce98-4e4e-9e2d-ecfc9e19fc79,SharePoint_Config_2010,PerformancePoint Service Application_c1a8062656434a24a9c53f05fc8144f7,Search_Service_Application_CrawlStoreDB_76166d368e4a4ef58aabf8df57d7c670,Search_Service_Application_PropertyStoreDB_1fc75775ee894fd2aa0c4d1e7c75f0c7,Application_Registry_Service_DB_8e93a305ea904c81a34a3dd205265fc7,SharePoint_AdminContent_e0021dbb-cc00-4b58-a16d-9c4c481228ff,WSS_Content,WSS_Content_KM,WSS_Content_MySites,Search_Service_Application_DB_bfdf7354e7f84b1281121c7bdca7b43f,Managed Metadata Service_ff52c4f0cd504d938cd1b3dc9ef9ae8b,Profile DB,WSS_Logging,Sync DB,WebAnalyticsServiceApplication_ReportingDB_894b25ce-a2ba-4c7c-885e-08b3924deec8"

#Convert comma separated into an Array
$DatabaseNames = $DatabaseColl -split ","

#Backup Each Database
Foreach($DBName in $DatabaseNames)
{
  write-host "Backing up the database: $($DBName)"
  Backup-SqlDatabase -ServerInstance $SQLInstance -Database $DBName -BackupFile "$($BackupPath)\$($DBName).bak"
}

Step 3: Restore all databases to the target SQL Server instance
Copy all backup files from the source server to the target and then, use the below PowerShell script to restore SQL Server databases in bulk. Make sure the original location (as in the source database server) do exists in the target server.

PowerShell script to restore SQL Server databases in bulk:
#Import SQL PowerShell module
Import-Module SQLPS –DisableNameChecking

#Configuration parameters
$SQLInstanceName="Cre-SQL-002"
$BackupPath="E:\Backup\"

#Get all Backup files
$BackupFilesColl = Get-ChildItem –Path $BackupPath | where {$_.extension -eq ".bak"}

#Iterate through each backup file
Foreach($BackupFile in $BackupFilesColl)
{
 #Get the full path of the backup file
        $DatabasePath = $BackupPath + '\' + $BackupFile

 #Frame the Database Name
        $DatabaseName = $BackupFile.ToString().Replace(".bak", "")

 #Restore the database
 write-host "Restoring Database: $($DatabaseName)"
 Restore-SqlDatabase -ServerInstance $SQLInstanceName -Database $DatabaseName -BackupFile $DatabasePath
}
Backup-Restore All SharePoint Databases in SQL Server using PowerShell

Step 4: Change SQL Server Alias to Point your New SQL Server:
and as a final step, change your SQL Alias from SharePoint servers to point new SQL server instance. Here is my post on configuring SQL server alias: How to Create SQL Server Alias for SharePoint. Do IISReset once done!

These scripts can be used in scenarios, such as:
  • During SharePoint migrations, where you may be taking all SharePoint databases to a new SQL Server instance.
  • When you have to move SharePoint databases from a Single standalone SQL Server to a highly available cluster, or SQL Server AlwaysOn cluster.


You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.
*Sponsored


Sunday, August 28, 2016

Check if SharePoint web application uses Claims Based Authentication or Classic mode?

How to check if the SharePoint web application is using Claims or Classic mode authentication? Well, To determine if the particular web application is using Claims or Classic Authentication, from SharePoint 2013 Central Administration follow these steps:
  • Go to SharePoint Central Administration site 
  • Click on Application Management >> Select Manage Web Applications.
  • Select the appropriate Web Application for which you would like to find the authentication type.
  • Click "Authentication Providers" button from the ribbon. you will see the following:
  • For Claims based authentication, it will show "Claims Based Authentication". When its on Classic Mode, You'll see "Windows".
    sharepoint 2013 check claims based authentication
PowerShell to Check SharePoint web application uses Claims Based Authentication
You can use SPWebApplication.UseClaimsAuthentication property to determine whether claims based authentication is enabled or not. Here is how to figure out whether a web application is using claims authentication or classic authentication mode using PowerShell.
  • Open SharePoint 2013 Management Shell,and enter these PowerShell Cmdlets.
    $WebAppURL="http://intranet.crescent.com/"
    (Get-SPWebApplication $WebAppURL).UseClaimsAuthentication

This script gives you either true or false depending on your web application's authentication settings.
sharepoint check if claims based


You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.
*Sponsored


Saturday, August 27, 2016

Create User Profile Synchronization Connection in SharePoint 2016 using PowerShell

User Profile Service Synchronization Connection in SharePoint specifies the source for importing user profiles from active director or any other profile source. To add new synchronization connection in SharePoint 2016:
  • Go to SharePoint 2016 Central Administration >> Application Management 
  • Manage Service applications >> select User Profile Service application 
  • On User profile service application page, click on "Configure Synchronization Connections" >> Create New Connection 
  • Fill in the details according to your environment.
    create user profile synchronization connection powershell
    Add new synchronization connection 

PowerShell Script to create user profile synchronization connection:
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

#Configuration Parameters
$ImportDomain = "Crescent"
$ImportUserName="SP16_ProfileImport"
$ImportPassword = Read-host "Enter the Password for Import Account:" -AsSecureString 
 
$ServiceAppName="User Profile Service Application"
$ImportOU="OU=Users,DC=Crescent,DC=com"
$ForestName="Crescent.com"
$FilterDisabledUsers = $True
 
#Get User Profile Service application
$UPS=Get-SPServiceApplication -Name $ServiceAppName

#Create User Profile Synchronization Connections 
Add-SPProfileSyncConnection -ProfileServiceApplication $UPS -ConnectionForestName $ForestName -ConnectionDomain $ImportDomain -ConnectionUserName $ImportUserName -ConnectionPassword $ImportPassword -ConnectionSynchronizationOU $ImportOU -ConnectionUseDisabledFilter $FilterDisabledUsers


You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.
*Sponsored


Saturday, August 20, 2016

SharePoint Online: Create a Folder using PowerShell-CSOM

Create folder in SharePoint Online document library
Folders are used to organize files in SharePoint, similar to what we do in our computer. You can add a folder to SharePoint online list or library by following below steps.

How to Create a folder in SharePoint Online?
To create a folder in SharePoint online, Follow these steps:
  • Login to your SharePoint online site, Navigate to your document library in which you want to create a folder.
  • On the ribbon, click on Files tab (Items tab, if its a list, instead of library)
  • Click New Folder
    create new folder sharepoint online
  • In the Create A New Folder window, enter the folder name and click Save!
    sharepoint online create folder powershell
Now you can see your new folder in the Document Library. Please note, creating a folder is less preferred compared with adding a meta-data column to classify data in SharePoint!

How to Enable the "New Folder" option?
What if the New Folder option is grayed out? If the New Folder button isn't available, you can enable it.
  • Navigate to the List or Library setting >> click Advanced settings.
  • In the Folder section, Click "Yes" option to Make "New Folder" option available.
  • Click OK to save your changes.
Now, you should get "New folder" in the SharePoint list 

SharePoint Online: Create Folder using PowerShell-CSOM: 
Lets create folder in SharePoint document library using PowerShell.
#Load SharePoint CSOM Assemblies
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
  
##Variables for Processing
$SiteUrl = "https://crescent.sharepoint.com/"
$ListName="Shared Documents"
$FolderName="Reports"
$UserName="salaudeen@crescent.com"
$Password ="Password Goes here"
 
#Setup Credentials to connect
$Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($UserName,(ConvertTo-SecureString $Password -AsPlainText -Force))

Try { 
    #Set up the context
    $Context = New-Object Microsoft.SharePoint.Client.ClientContext($SiteUrl) 
    $Context.Credentials = $credentials
  
    #Get the List Root Folder
    $ParentFolder=$Context.web.GetFolderByServerRelativeUrl($ListName)

    #Create New Folder
    $Folder = $ParentFolder.Folders.Add($FolderName)
    $ParentFolder.Context.ExecuteQuery()

    Write-host "New Folder Created Successfully!" -ForegroundColor Green
}
catch {
    write-host "Error: $($_.Exception.Message)" -foregroundcolor Red
} 

Create Sub-Folder at given path using PowerShell:
We can add a folder or sub-folder to any existing library or folder using PowerShell.
    #Set up the context
    $Context = New-Object Microsoft.SharePoint.Client.ClientContext($SiteUrl) 
    $Context.Credentials = $credentials

    #Create New Sub-Folder
    $Folder=$Context.Web.Folders.Add("Shared Documents/Reports/V2")
    $Context.ExecuteQuery()

    Write-host "Folder Created at: " $Folder.ServerRelativeUrl -ForegroundColor Green



You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.
*Sponsored


Saturday, August 13, 2016

Configure Continuous Crawl in SharePoint 2016

SharePoint 2013 introduced a new Search crawl type called "Continuous Crawls" to keep the search results as fresh as possible. If enabled, Continuous crawl automatically starts at predefined intervals - By default the interval for continuous crawls is every 15 minutes.

How continuous crawl works in SharePoint?
Continuous crawl crawls modified content such as content that are added, changed, or deleted since the last crawl. Also, an incremental crawl automatically runs every four hours for content sources that have continuous crawl enabled to re-crawl any items that repeatedly return errors, as continuous crawl does not process or retry items that return errors more than three times.

Continuous crawl vs incremental crawl SharePoint 2016:
Incremental starts at a particular time and repeats regularly at specified schedule. But continuous crawl automatically starts at 15 minutes time intervals by default. Multiple continuous crawls can run at the same time whereas you cannot run multiple full crawls or incremental crawls for the same content source in parallel - you'll have to wait until the existing one completes.
Continuous crawl is available only for SharePoint content sources!

Enable continuous crawl in SharePoint 2013:
Continuous crawl is to be enabled per SharePoint content source. To enable Continuous Crawl, follow these steps:
  • Go to Central Administration >> Service Applications >>Open the Search Service Application
  • Click on the Content Sources link from the left navigation
  • In the content source page, Select the content source such as "Local SharePoint Sites"
  • You will get Edit Content Source page. Scroll down and set "Enable Continuous Crawls" option under the Crawl Schedule section.
  • Click on OK button to save the changes. enable continuous crawl sharepoint 2013
That's all! You are done with enabling Continuous Crawl.

Disable continuous crawl SharePoint 2013
To disable the continuous crawl,
  • Open Search service application >> From the target content source's context menu, choose "Disable Continuous Crawl".
  • Confirm the prompt to disable continuous crawl. This will disable the continuous crawl.
  • Once its disable, SharePoint 2013 automatically triggers an incremental crawl.
disable continuous crawl sharepoint 2013
SharePoint 2016 search continuous crawl performance: The Crawler Impact Rules controls the maximum number of requests that can be executed by the server (By default its 8).

Technet reference on Manage continuous crawls in SharePoint Server 2016: https://technet.microsoft.com/en-us/library/jj219802(v=office.16).aspx

You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.
*Sponsored


You might also like:

Related Posts Plugin for WordPress, Blogger...