Sunday, April 17, 2016

How to Add User to SharePoint Group using PowerShell

Requirement: Add User to SharePoint group using PowerShell

From SharePoint site, you can follow below steps to add an user to particular group.
  • Go to your SharePoint site and click on Site Settings gear icon >> Select "Site settings"
  • Click on "People and groups" link under "Users and Permissions"
  • Click on the SharePoint user group to which you want to add users, such as "Marketing Members"
  • Click on "New" button >> and select "Add Users".
    sharepoint group add user powershell
  • Enter the names of the users to add. Make sure all your entries are resolved.
  • Click on "Share" button to to complete add user to SharePoint group.
    sharepoint powershell add user to group
The users have entered are not added to the group!

Add User to SharePoint group with PowerShell
There are two cmdlets provided by SharePoint to add user to group using PowerShell.

New-SPUser New-SPUser cmdlet adds an existing active directory (or whatever authentication provider) to SharePoint to the appropriate group specified.
New-SPUser -UserAlias "domain\user" -Web "" -Group "Marketing Owners"
This will create a add a new User to SharePoint site to the particular group. If you execute this command for the next time, (without deleting the user from site collection) this command has no effect!

Set-SPUser cmdlet adds an existing SharePoint user to an existing group in the given site.
Set-SPUser -Identity "domain\user" -Web "" -Group "Marketing Owners"
This will add existing SharePoint users account to the provided group, but will give error when you try add a new user to SharePoint site. (which is obvious! We can't set the user property, if the user doesn't exists in SharePoint site, isn't it?)

Add User to SharePoint Group using PowerShell Script
Other than New-SPUser and Set-SPUser cmdlets, lets use the native object model APIs to add user to group in SharePoint using PowerShell.
#Get the Web
$web=Get-SPWeb ""
#Get the SharePoint Group
$Group= $web.Groups["Marketing Owners"]
$userName = "domain\userName"

#Add User to the site collection
$user = $web.EnsureUser($UserName)

#Add User to the Group
$group.AddUser($user) vs web.sitegroup - SPWeb.Group refers the groups which are used in the specified SPWeb object (If SPWeb uses unique permissions). Whereas SPWeb.SiteGroups refers to a collection of all groups in the site collection.

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

Saturday, April 16, 2016

How to Upload List Template in SharePoint 2013

Requirement: Upload a list template in SharePoint 2013! SharePoint 2013 offers many list templates such as Task List, contacts, calendar, etc to create clones. At times, You may have to import a custom list template obtained from other sites into your SharePoint.

How to upload a list template in SharePoint 2013:
SharePoint list templates are XML-based definition of list settings, such as List fields, List views and optionally list items. List templates are stored as.stp files. To upload a list template in SharePoint, follow these steps:
  • Navigate to your Site collection. Click on "Site Settings" gear icon >> Choose "Site Settings".
  • Click on List Templates link under Web Designer Galleries
    upload a list template sharepoint 2013
  • From List Templates library, Click on "Upload Document" button from Files Tab
    how to upload list template in sharepoint online
  • Browse and Select your List template STP File and Click "OK" to upload the list template to SharePoint
    import list template stp sharepoint 2013
  • Provide a Name and Title to the template, Optionally the description.Click "Save" to finish uploading the list template to SharePoint.
    upload list template to sharepoint 2013
  • That's all. Now, If you go to "Add an App" page, you'll find your list template listed!
    how to upload list template in sharepoint 2013
PowerShell to Upload list template in SharePoint 2013:
To upload SharePoint list template using PowerShell, refer this post: How to upload list template in SharePoint 2013 using PowerShell

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

Wednesday, April 13, 2016

SharePoint 2016 Installation Guide - Step by Step

SharePoint 2016 is in RTM finally with all new features. Lets walk-through SharePoint 2016 installation process step by step:

System Requirements: What's my Server Farm Configuration?
Here is my SharePoint 2016 farm's server configuration (Hardware/software).
  • Windows Server 2012 R2 Standard as Server Operating system and SQL Server 2014 Standard SP1 as my SQL Server instance. 
  • All my servers running with 24 GB of RAM (minimum requirement: 16 GB. For single server installation: 24 GB) and Quad core processors. (64 bit of course!) and 120 GB in system drive and 250 GB as secondary drive (Min: 80 GB for system drive and 100 GB for applications).
Service Accounts:
  • Crescent\SP16_Setup - Setup  account used for installation. You must manually assign Member of Local Administrator group on all SharePoint Servers and SQL server and SysAdmin role at SQL Server instance. (In fact, it just needs: DBcreator & SecurityAdmin server roles and DBO rights on each SharePoint Databases).
  • Crescent\SP16_Farm - Farm account / Database access account. Necessary rights will be automatically granted on the SQL Server instance when you run SharePoint products configuration wizard.
Whats new in SharePoint 2016 Installation?
Its pretty much same as SharePoint 2013 installation, except the "Server Role" selection page. MinRole is introduced newly in SharePoint 2016.

SharePoint 2016 Server installation steps at high level:
  1. Install SharePoint 2016 prerequisites
  2. Install SharePoint  Server 2016
  3. Run Products configuration wizard
    SharePoint 2016 Server Farm Topology:
    Here is my small server farm topology for SharePoint 2016 with three servers. All these servers joined to my domain:
    Where to start Installation? Start with your Application Server! Your Application server hosts SharePoint 2016 central administration site and other necessary service applications.

    Step 1: Install Prerequisites

    We need to install SharePoint 2016 prerequisites before installing SharePoint Server 2016. Login with Setup account and start your SharePoint Server 2016 installation by installing the prerequisites. Prerequisites installer will add all necessary server roles (Application Server Role, Web Server (IIS) Role) ,downloads and installs all necessary components for SharePoint 2016.
    • Mount the ISO on the drive, launch "default.hta" file (or prerequisiteinstaller.exe). You'll see the same old Splash screen! Click on "Install software prerequisites" link under "Install"
      sharepoint 2016 installation guide
    • Accept License agreement and click "Next" button
      sharepoint 2016 installation step by step
    • Wait for the installation to proceed
      sharepoint 2016 install instructions
    • Prerequisites installer takes some time and will prompt for restart. After restart, re-run the prerequisites again! Restart and resume back.
    • Wait for the installation completed message. Click on "Finish" button to complete prerequisites installation.
      sharepoint 2016 install standalone

    Step 2: SharePoint Server 2016 Installation

    • After completing prerequisites installation, run the splash.hta file again and click on "Install SharePoint Server". sharepoint 2016 installation steps
    • You'll be prompted to enter the product key. I've used the 180 day Trial key: NQGJR-63HC8-XCRQH-MYVCH-3J3QR
      how to install sharepoint 2016 step by step
    • Accept license agreement
      install sharepoint server 2016
    • Choose a file location: Choose a file location for SharePoint Server and Search server index. Make sure there is sufficient disk space on the selected drive. You can use your secondary drive to store search index files. Click on "Install Now" button to start the installation process.
    • Wait for installation to complete. The installation wizard takes few minutes to complete.
    • Once completed, You'll be taken to Run Configuration wizard page. Tick the "Run the SharePoint Products Configuration Wizard now" check box and click on Close.

    Step 3: Run SharePoint Products Configuration Wizard

    • You'll be presented with the "Welcome to SharePoint Products" wizard. Run SharePoint Products configuration wizard by clicking "Next" button.
    • Click Yes for products configuration wizard restart services confirmation
    • On Connect to a server farm, choose Create a new server farm. If you are already have an existing SharePoint farm created, you'll have to choose the option "connect to an existing server farm". We'll be selecting this when we run products configuration wizard on our WFE server.
    • Specify configuration database settings: Enter your Database server name and proposed SharePoint farm's configuration database names. Enter the Farm account which will be used for database access.
    • On Farm security settings page, enter the Passphrase. You'll need this when you need to join the new server to an existing SharePoint server farm.
    • Specify Server Role. There are six roles listed in this page. You can select whichever applicable to you. This is critical as in previous versions:  If you selected Single-Server Farm, then you can't scale out your SharePoint farm to Multi-Server environment! So if you plan to extend your farm to Multi-Server farm in future, make sure you have selected the Custom (MinRole) or Application server role. In my case, I've selected Application server role. Click on Next to proceed.
    • Enter the Port for SharePoint 2016 Central Administration site. Choose the authentication provider. Click Next to continue.
    • You'll see SharePoint products configuration wizard performing several tasks as in the below progress screen. Wait until all 10 installation tasks to complete.
    • Once completed, SharePoint products configuration wizard presents you the verify screen. You can click Back in case, you want to change any setting. Click Next to proceed.
    • Wait for the Configuration successful page. Click on "Finish" to complete SharePoint 2016 installation process.
    Once you click "Finish" button, you'll be taken to Initial Farm Configuration Wizard page in SharePoint 2016 Central Administration site.

    Repeat all these steps in your Web Front end Server. Choose "Front-End" Server role for Web Front end. Once done, you can proceed with creating web applications, Service applications and site collections.

    FAQ's and Known issues in SharePoint 2016 Installation:
    • Can I use a Single Server for SharePoint 2016 installation?
      Sure, You can use a single server. However, You need to have SQL Server 2014 installed on the server first! Unlike SharePoint 2013, SharePoint 2016 doesn't install SQL Server Express automatically as part of Single server mode.
    • Prerequisiteinstaller.exe: The system cannot find the drive specified
      This happens when you mount an ISO file and after server reboot, it doesn't get mounted automatically. Remedy is simple: Mount the ISO and run:Start "Launch SharePoint preparation tool" "E:\Prerequisiteinstaller.exe" /continue

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

    Monday, April 11, 2016

    InfoPath Form: Show Thank You Page on Submit

    To deliver better user experience, wanted to show a neatly designed thank you page on submitting a customized SharePoint list form in InfoPath. Although we can customize the standard popup message shown on successfully submissions through "Submit Options" under Data tab, we wanted to customize the entire look and feel.

    The idea is: Create a new view for Thank you page and then change the view after submitting data. Here is how to implement thank you page for InfoPath forms.
    • Open your form template in InfoPath Form Designer
    • Click on "Page Design" tab and create new view.
    • Give a name to your view (say: ThankYou), and place image/text appropriately. Here is mine:
      infopath form thank you page
    • Create a button for "Submit". From the ribbon select "Manage Rules". In the "submit" button's Rules, Add >> and then Action.
      • Submit using Data connections
      • Switch to view: ThankYou
    infopath thank you page
    That's all! Now we let the end-user to know, form submitted successfully.

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

    Tuesday, April 5, 2016

    Enable "Link to Item" or "Edit Menu" on Any Column of the List in SharePoint

    There is a list called "Projects" where the default title filed made hidden and now the problem is: User wants to have the link to View Item on "Project Name" Field.

    By default "Title" field of the list has link to item and edit menu options in it. If you want to change link to item or edit menu options on any other column of the list - There is no option!
    sharepoint change link to item field
    Solution: How to change link to item field in SharePoint?
    To enable link to item and/or edit menu options on any of the SharePoint list column, follow below steps:
    • Open your List view page in SharePoint Designer using "Edit File in Advanced Mode"
    • Search for <ViewFields> Tag. Pick the appropriate field to have link to item functionality
    • Add: LinkToItem="TRUE" to it. If you want to have Edit Menu, then add: ListItemMenu="TRUE" or you can add both.E.g.
    <FieldRef Name="ProjectName" LinkToItem="TRUE" ListItemMenu="TRUE" />
     sharepoint link to item with edit menu
    Save and close the page. Now, if you go back to your view, the "Project Name" field will have the link to DispForm.aspx page of the item!

    Set Link to Item or ECB Menu on a particular column in SharePoint 2016:
    While the above solution works on both SharePoint 2010 and in SharePoint 2016, found the same "LinkToItem" doesn't work on SharePoint 2016, but "linkToItem" works (case sensitive!)
    <FieldRef Name="ProjectName" linkToItem="TRUE" ListItemMenu="TRUE" />
    link to item with edit menu sharepoint change
    Here is the Result in action: link to item with edit menu in custom column!
    sharepoint change link to item field

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

    Sunday, April 3, 2016

    Get List Fields in SharePoint using PowerShell

    Requirement: Get all Fields from a SharePoint list using PowerShell.

    PowerShell Script to get all List Fields, Internal Name and Field types:
    Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
    #Configuration Parameters
    $ListName= "Quick Links"
    #Get the List
    $List = (Get-SPWeb $SiteURL).Lists.TryGetList($ListName)
    Write-Host "Field Name | Internal Name | Type"
    Write-Host "------------------------------------"
    #Loop through each field in the list and get the Field Title, Internal Name and Type
    ForEach ($Field in $List.Fields)
        Write-Host $Field.Title"|"$Field.internalName"|"$Field.Type
    This PowerShell script gets all column names, internal name and column types from the given SharePoint list!
    sharepoint powershell get list column

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

    You might also like:

    Related Posts Plugin for WordPress, Blogger...