Sunday, May 31, 2015

"There was an error during Installation, The tool was unable to install Application Server Role, Web Server (IIS) Role." In SharePoint 2013 Products Preparation Tool

Problem: SharePoint 2013 Products Preparation Tool  failed with an error "There was an error during Installation - The tool was unable to install Application Server Role, Web Server (IIS) Role." during prerequisites installation in Windows Server 2012 R2.
There was an error during Installation, The tool was unable to install Application Server Role, Web Server (IIS) Role.

Solution: Mount the Windows 2012 R2 ISO into the drive and Install the roles offline from Windows Server Installation disk.

PowerShell script to Add necessary Roles & features for SharePoint 2013 (Prerequisites)
Import-Module ServerManager

Add-WindowsFeature NET-WCF-HTTP-Activation45,NET-WCF-TCP-Activation45,NET-WCF-Pipe-Activation45 -Source E:\Sources\sxs

Add-WindowsFeature Net-Framework-Features,Web-Server,Web-WebServer,Web-Common-Http,Web-Static-Content,Web-Default-Doc,Web-Dir-Browsing,Web-Http-Errors,Web-App-Dev,Web-Asp-Net,Web-Net-Ext,Web-ISAPI-Ext,Web-ISAPI-Filter,Web-Health,Web-Http-Logging,Web-Log-Libraries,Web-Request-Monitor,Web-Http-Tracing,Web-Security,Web-Basic-Auth,Web-Windows-Auth,Web-Filtering,Web-Digest-Auth,Web-Performance,Web-Stat-Compression,Web-Dyn-Compression,Web-Mgmt-Tools,Web-Mgmt-Console,Web-Mgmt-Compat,Web-Metabase,Application-Server,AS-Web-Support,AS-TCP-Port-Sharing,AS-WAS-Support, AS-HTTP-Activation,AS-TCP-Activation,AS-Named-Pipes,AS-Net-Framework,WAS,WAS-Process-Model,WAS-NET-Environment,WAS-Config-APIs,Web-Lgcy-Scripting,Windows-Identity-Foundation,Server-Media-Foundation,Xps-Viewer -Source E:\Sources\sxs

Where E:\ is your DVD drive.

Other Solutions:
  • Copy "C:\Windows\System32\ServerManager.exe" and rename as "C:\Windows\System32\ServerManagerCMD.exe"
  • Try adding IIS Role from Server Manager
  • Try registering .Net framework using: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet_regii -enable -i


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


Saturday, May 30, 2015

How to Read-Update Multiple lines of text Field Value in SharePoint using Powershell

PowerShell to Get Value from Multiple lines of text field:
To Read the value of multiline text field in SharePoint using PowerShell, use this script:
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue 

#configuration parameters
$WebURL="https://portal.crescent.com/selfservice/"
$ListName="Service Requests"
$ItemID=2
$FieldName="Request Description"

#Get Web, List, Item and Field
$Web= Get-SPWeb $WebURL
$List= $Web.Lists[$ListName]
$Item = $List.GetItembyID($ItemID)

#Get the field
$Field = $Item.Fields.GetField($FieldName)

#Retrieve field value with all formats applied
#$Field.GetFieldValueAsHTML($Item[$FieldName])
$MultilineValue=$Item[$FieldName]

#Get Field value Text alone -Without Formatting
$MultilineTextVale=$Field.GetFieldValueAsText($Item[$FieldName])

Update Multiple lines of text value using PowerShell:
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue 

#configuration parameters
$WebURL="https://portal.crescent.com/selfservice/"
$ListName="Service Requests"
$ItemID=2
$FieldName="Request Description"

#Get Web, List, Item and Field
$Web= Get-SPWeb $WebURL
$List= $Web.Lists[$ListName]
$Item = $List.GetItembyID($ItemID)

#Update the field value
$Item[$FieldName]="Service Request No: 3435"
$Item.update()

#update HTML formatted value
#$Item[$FieldName]="Service Request No: <br/> <b> 3435</b>"
$Item.update()


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


Thursday, May 28, 2015

Add New Content Source in SharePoint 2013 Search using PowerShell

Requirement: Create new search content source in SharePoint 2013.

PowerShell script to add new content source:
Here is the PowerShell script to create new content source in SharePoint 2013 search.
Add-PSSnapin Microsoft.SharePoint.Powershell -ErrorAction SilentlyContinue

#Variables for new content source creation
$ContentSourceName= "Intranet Portal" #default "Local SharePoint sites"
$ContentSourceType="SharePoint"
$ContnetSourceURL="http://portal.crescent.com"

#Get the search service application
$SSA = Get-SPEnterpriseSearchServiceApplication #-Identity "Search Service Application Name"

#Check if the given content source Name exits already
$ContentSource = Get-SPEnterpriseSearchCrawlContentSource -SearchApplication $SSA | where {$_.Name -eq $ContentSourceName}
if ($ContentSource)
{
    write-host "Content Source Name already exist!" -f Red
    exit
}
 
#Create new content source
$ContentSource = New-SPEnterpriseSearchCrawlContentSource -SearchApplication $SSA -Type $ContentSourceType `
          -name $ContentSourceName -StartAddresses $ContnetSourceURL -MaxSiteEnumerationDepth 0

write-host "New Content Source has been created!" -f Green

#To delete a content source, use: 
#Remove-SPEnterpriseSearchCrawlContentSource -SearchApplication $SSA -Identity $ContentSourceNames
You must run full crawl for any new content source created. Here is how: How to Start SharePoint Search Crawl using PowerShell

New-SPEnterpriseSearchCrawlContentSource reference in technet.

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


Force Stop SharePoint Search Crawl using PowerShell

Problem: SharePoint 2013 search crawl process is running infinitely!

Solution:
Tried stopping the crawl process from search administration page of SharePoint 2013 central administration, but failed.
force stop crawl sharepoint 2013 powershell
PowerShell to rescue! This script checks whether the crawler status is "Idle" for the given content source. If not, it stops the crawl activity and wait until the status is changed to Idle.

Stop Search Crawl for All Content Sources:
#Stop the crawl for all content sources
Get-SPEnterpriseSearchCrawlContentSource -SearchApplication "Search Service Application" | ForEach-Object {  
    If($_.CrawlStatus -ne "Idle") 
    {
        Write-Host "Stopping crawl on Content source $($_.Name)..."  
        $_.StopCrawl()  

        While ($_.CrawlStatus -ne "Idle")
     {
            Write-Host "Waiting to crawl to be stopped..." -f DarkYellow
            sleep 3
        }
        write-host "Crawl Stopped Successfully!" -f DarkGreen
    }
    else
    {
        write-host "Crawl Status of the Content source '$($_.Name)' is Idle!" -f DarkGreen
    }
}

PowerShell script to force stop SharePoint 2013 search crawl on specific content source:
To stop Search crawl forcefully in SharePoint, use this script. 
Add-PSSnapin Microsoft.SharePoint.Powershell -ErrorAction SilentlyContinue

#Content source Name
$ContentSourceName= "Crescent Portal" #default "Local SharePoint sites"
 
#Get the search service application
$SSA = Get-SPEnterpriseSearchServiceApplication #-Identity "Search Service Application Name"
 
#Get the content source
$ContentSource = $SSA | Get-SPEnterpriseSearchCrawlContentSource -Identity $ContentSourceName
 
#Check if Crawler is not already running
if($ContentSource.CrawlState -ne "Idle")
    {
        Write-Host "Stopping Crawl..."           

        $ContentSource.StopCrawl()

        #Wait till its stopped
        while($ContentSource.CrawlState -ne "Idle")
        {
            Write-Host "Waiting to crawl to be stopped..." -f DarkYellow
            sleep 5
        }
        write-host "Crawl Stopped Successfully!" -f DarkGreen
    }
  else
    {   
        Write-Host "Search Crawl is not running!" -f Red
    }

Disable continuous crawl for all SharePoint content sources
$SSA =  Get-SPEnterpriseSearchServiceApplication
$ContentSources = $SSA | Get-SPEnterpriseSearchCrawlContentSource | Where{$_.Type -eq "SharePoint"} 
foreach ($cs in $ContentSources)
{ 
  $cs.EnableContinuousCrawls = $false 
  $cs.Update() 
}

If you still face the trouble of crawl stuck in stopping state, Go to services console and restart SharePoint Server Search!

I used this script when the crawler stuck in the stopping state! Related post: Start SharePoint Search Crawl 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, May 27, 2015

Enable Anonymous Users to Add New List Items in SharePoint

Problem: Add items greyed out for Anonymous access users. We got to enable anonymous users to add  list Items in a SharePoint list.

Solution: By default, Add/Edit/Edit access is disabled for anonymous users. They are granted only with "Read" access. But for a "Contact Us / Feedback" list in our public SharePoint site, we had to enable anonymous user to submit their questions and feedback (add new list items). 
sharepoint 2013 anonymous access add items greyed out
 So, How to enable Anonymous users to add list items in SharePoint? Follow these steps:
  • Go to the list settings >> Permissions for this list
  • Click on "Stop Inheriting Permissions" from Permissions tab of the Ribbon. 
  • You'll see the "Anonymous Access" Icon appearing on the ribbon. Click on that.
  • Enable "Add Items - Add Items to lists" check box and click "Ok"
     sharepoint 2013 anonymous access add items
  • Here is the result in action
     sharepoint anonymous access add list item
Now, anonymous access users can add list items in SharePoint!

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


Getting Login Prompt on Anonymous Access Enabled SharePoint Sites?

Problem: We Enabled anonymous access to a SharePoint 2013 and users still getting Login prompts!

Solution: Here is the check list for troubleshooting.
  1. Anonymous access must be turned on both in at Web Application level and at SharePoint site level. Double check your settings with How to Enable Anonymous Access in SharePoint 2013 
  2. On publishing sites, try disabling the feature "Limited-access user permission lockdown mode" at site collection level.
     sharepoint anonymous access prompt login
  3.  If the default home page, say default.aspx page is not published & approved, users get login prompt!
  4. If any referenced resources like images, scripts, css files, etc from other libraries requires authentication - You'll get authentication prompt! E.g. You may have a css style sheet from the library "", which may not allow anonymous access! Check the permission for the specific library and grant anonymous users to "Read" the content.
  5. Navigate to the IIS Virtual directory on File system using Windows Explorer, Go to Security tab, make sure that "Everyone" has Read privileges. If not, Add it!
  6. In IIS, Expand your web application, Click on "Authentications", Make sure "Anonymous Authentication" is enabled.
    sharepoint anonymous access prompt for login
  7. In SharePoint 2013 Central Administration >> Application Management >> Manage Web applications, select the web application and Click on "Anonymous Policy". Make sure that "None – No Policy" is selected.
  8. If you enabled Anonymous access at list/library level: Delete unique permissions once, stop inheriting permissions and then grant anonymous access again.


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


Export SharePoint Users and Group Permissions to Excel

Here is the shortcut to export SharePoint users and groups permission to Excel.
  1. Open your SharePoint site in Internet Explorer. Navigate to either Site permissions or any User group. 
  2. Right click on the users list page, choose "Export to Excel" item.export sharepoint user groups to excel
You may need to reformat it a bit! Here is it would look like:
export sharepoint user permissions to excel
This trick works in all versions of SharePoint including, SharePoint 2010, SharePoint 2013, and in SharePoint 2016! Here is the PowerShell way to Export users and group permissions to excel:
Export SharePoint Users and Groups to Excel using PowerShell

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


Tuesday, May 26, 2015

Reset Search Index in SharePoint 2013 using Powershell

Problem: SharePoint 2013 search crawling process got stuck and we got to reset the corrupted search index.

Solution: Follow these steps to reset search index in SharePoint 2013.
  • Go to SharePoint 2013 Central Administration >> Service Applications 
  • Pick your Search Service Application 
  • In Search Administration page, Click on "Index Reset" link under crawling section of the left navigation menu.
    Reset Search Index in SharePoint 2013
  • In the index reset page, click on "Reset Now" button to reset search index in SharePoint 2013.
Before resetting search index, make sure no search crawls are in progress - Stop all search crawls, disable continuous crawl - otherwise, index reset may get stuck! After index reset, You must run full crawl to enable search results!

PowerShell script to reset index in SharePoint 2013:
At times, you may have to do it with PowerShell for reasons, such as:
  • When you try to reset search index from Web UI, you get timeouts error on large index
  • You may want to partially reset index for only certain content source
Reset search index in SharePoint 2013 with PowerShell:
Here is the PowerShell to reset search index partially (Reset search index for a specific content source):
Add-PSSnapin Microsoft.SharePoint.PowerShell –ErrorAction SilentlyContinue

#Get Search service application
$ssa = Get-SPEnterpriseSearchServiceApplication

#Content Source Name
$ContentSourceName = "Crescent Portal"

#Get the content source 
$ContentSource = Get-SPEnterpriseSearchCrawlContentSource -Identity $ContentSourceName -SearchApplication $SSA 

#Get Each Start Address
$StartAddresses = $ContentSource.StartAddresses | ForEach-Object { $_.OriginalString } 

#Clear Indexed content starts with custom contnet source
$ContentSource.StartAddresses.Clear()

#Re-add the start address to content source
ForEach ($Address in $StartAddresses ){ $ContentSource.StartAddresses.Add($Address) }

Reset SharePoint 2013 Search Index:
To Reset SharePoint 2013 search index completely using PowerShell, use this cmdlet:
(Get-SPEnterpriseSearchServiceApplication).reset($true, $true)
Where, the $True parameter denotes: Disable Alerts & Ignore Timeout error.
If you still get Timeout errors, Clear SharePoint configuration cache and then try again!

Related post: How to Stop SharePoint Search Crawls


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


Delete Web application using PowerShell in SharePoint 2013

To delete SharePoint Web application using PowerShell use this cmdlets:

Delete Web Application and All its zones:
#Web Application URL to delete
$WebAppURL="http://sharepoint.company.com" 

#sharepoint 2013 powershell delete web application
Remove-SPWebApplication -identity $WebAppURL -Confirm
This deletes the entire Web application and its all zones:

Remove Web Application Along with All its Databases and IIS Web Site:
To remove the Web application along with its content databases and the IIS Web site, use the switches: -DeleteIISSite and -RemoveContentDatabases
#Web Application URL to delete
$WebAppURL="http://sharepoint.company.com" 

#Remove the web application and its databases & IIS Web Application
Remove-SPWebApplication -identity $WebAppURL -Confirm -DeleteIISSite -RemoveContentDatabases
delete sharepoint web application using powershell

Delete the Extended Web Application zone:
To Removes the Extended Web Application zone, say: Internet, use:
#Web Application URL to delete
$WebAppURL="http://sharepoint.company.com" 

#sharepoint 2013 powershell delete web app
Get-SPWebApplication http://sitename | Remove-SPWebApplication -Zone "Internet" -Confirm
Make sure you logged in as a "Farm Administrator" with "Shell Access" rights to delete web applications 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, May 25, 2015

SharePoint Group vs Active Directory Group - Which is Best?

So you need to determine the best way to manage SharePoint users, Whether to use SharePoint groups or Active Directory groups to manage permissions in SharePoint? Well, Both SharePoint Group and AD Group have their own advantages and disadvantages. Let me list down some of them:
  • Manageability: Any SharePoint site owner/admin can manage users on SharePoint groups within SharePoint (Self-Service!). But AD group creation and adding/removing users can be done only by AD administrators, unless delegated. So, to create new users or removing accounts you may have to wait for AD Admins/Help-desk! However, AD Groups Serves better in Centralized management, performance, Minimum administration efforts
  • Scope: Since AD Groups are created globally, you can re-use them in any different SharePoint site collections (even in different systems like File Shares, Exchange, etc) . E.g. You may be having existing department wise AD groups created, say "Sales Team" and you can grant permission to any SharePoint site collection to the AD group. But SharePoint groups are scoped at site collection level and can't be re-used beyond that boundary. So, If you have an existing SharePoint group with 5000 users, you'll end-up recreating it in a different site collection (Although PowerShell can help!)
  • Users from Multiple Authentication Sources: AD Group consists of users from AD, but SharePoint groups can be the combination of users from AD as well as non-Active directory authentication sources like SQL Server, LDAP, Live, Google, Facebook, Yahoo, etc.
  • List All Users of the Group - If you want to list users of the group, SharePoint groups can be listed with "Site Users" web part. But you can't do it with AD Groups - You can't look inside them from SharePoint (without custom solutions!) SharePoint considers AD group as a single user.
  • Nested Groups: AD Groups can be nested, But SharePoint groups can't be added under any other SharePoint group. (However, you can add a AD Group inside SharePoint group!)
  • Group E-Mails: If you use SharePoint Group, There is no way to send alerts to all of them OOTB, But you can use E-mail enabled AD Group to subscribe to an Alert in SharePoint! 
  • Audience targeting - does not work with AD groups, only with SP security groups!
  • Orphaned Users - When you delete a user in AD, SharePoint groups can still hold them as orphan users!
  • securable objects with unique permissions - When you have a requirement for dynamically changing security needs, SharePoint groups provides better flexibility.


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


Sunday, May 24, 2015

Create List from Custom List Template in SharePoint using PowerShell

Requirement: Create a SharePoint list from a custom template using PowerShell

How to create SharePoint list from a template?
List templates in SharePoint saves your time by providing template on any existing list or library, which comprises of all columns and optionally the data from the source list. You can create any number of copies from the template (or source list copy)

Assuming you have an existing list template in the site, Here is how to create a list from list template in SharePoint.
  • Navigate to SharePoint site >> Click on Settings gear icon and click "Add an app"
  • In "Find an App" search box, enter your list template name such as "Project template". You can also Scroll down and use the pagination to move to the next page (custom list templates will be in second page!) and pick your list template.
  • Click on the custom list template shown
    sharepoint create list from template powershell
  • Provide a name for your new list and click on "OK"
  • You will see a new list created with same list schema, and also data if you selected “Include Content” when creating the list template originally.

PowerShell script to create a SharePoint list from list template:
Lets create a list using template in SharePoint with PowerShell.
Add-PSSnapin Microsoft.SharePoint.PowerShell –ErrorAction SilentlyContinue

Function Create-ListFromTemplate($WebURL, $ListName, $TemplateName)
{
    #Get the Web from URL
    $Web = Get-SPWeb $WebURL

    #Get the Specific list template
    $Template = $web.site.GetCustomListTemplates($Web) | where {$_.InternalName -match $TemplateName }

    #Check if given template name exists!
    if($Template -eq $null)
    {
        Write-host "Specified list template not found!" -f Red
        exit
    }

    #Create list using template in sharepoint 2013
    $web.Lists.Add($ListName, $ListName, $Template)
    Write-host "New List Created from Custom List template" -f DarkGreen 
}

#Variables
$WebURL="http://intranet.crescent.com"
$ListName="Project-607"
$ListTemplateName="ProjectTemplate"

#Call the function to create list from template
Create-ListFromTemplate $WebURL $ListName $ListTemplateName
This script creates list from template (.stp) in SharePoint.
create custom list from template sharepoint


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


How to Uninstall SharePoint 2013 - Complete Steps

Its a pretty common question and we stuck here often: How to Uninstall SharePoint 2013 completely from the server? Remove Server option From Central Administration >> Servers in Farm page? NO!! You can't uninstall SharePoint 2013 with this option. Remove server option must be used only when a particular server is no longer available and you want to remove it from your SharePoint farm.

Follow these steps to uninstall SharePoint 2013.
  • Go to Control Panel (Shortcut: Appwiz.cpl ), Pick Microsoft SharePoint Foundation 2013 (or Server!) and click on "Change" button.uninstall sharepoint server 2013
  •  In the Change your installation of Microsoft SharePoint Server 2013 page, Choose Remove, and then click Continue.how to uninstall sharepoint 2013
  • A confirmation message appears. Click Yes to remove SharePoint 2013.
     uninstall sharepoint 2013 server
  • A warning message appears. Click OK to continue.
     uninstall sharepoint 2013 manually
  • Watch the uninstall progress..
    how uninstall sharepoint 2013
  • Wait for the "Successfully uninstalled" message.
But wait! When you uninstall SharePoint 2013 with above steps, most of the files and folders are deleted. However, There are objects that needs our manual intervention.

Clear IIS Sites and Virtual Folders. Remove physical files 
We got to manually delete web applications created in IIS and their virtual folders from the file system.

Delete Search Index Files:
In search index servers, remove the search index manually. To get search index files location, Run these PowerShell cmdlets:
$SearchInstance = Get-SPEnterpriseSearchServiceInstance
$SearchInstance.Components

Delete IIS Log Files:

Delete 14/15 Hive customizations:
 
Delete the SharePoint Databases from Database Server:
Uninstalling SharePoint 2013 dismounts SharePoint databases from its web applications. But it doesn't remove any physical file stored in the database server. So, remove them all!

Technet reference on Uninstall SharePoint 2013: https://technet.microsoft.com/en-us/library/cc262874.aspx

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


Monday, May 18, 2015

SharePoint 2013: Update User's Display Name, E-mail using PowerShell

Requirement:  I came across an issue where the user display name appeared as domain/username instead of First name Last name.

Solution: We observed, If the user profile sync is not properly configured or running, we'll face this issue! Other than UPS solution, You can use PowerShell to update user's display name.
change user display name in sharepoint 2013
PowerShell change user display name in SharePoint 2013:
How to change the SharePoint user display name with PowerShell? Well, You can use Set-SPUser cmdlet.  Just provide the account identity, site and the new display name for user user.

Run this PowerShell cmdlet from SharePoint Management Shell.
#Set-SPUser -Identity "i:0#.w|Crescent\Salaudeen" -DisplayName "Salaudeen Rajack" `
           –Web http://intranet.crescent.com

sharepoint powershell change user name
Sync User Account Details such as Display Name, E-mail, Department from Active Directory:
Sometimes, user account details may be updated in AD but not synced in SharePoint. If that's the case, you can force sync user account details such as display name, E-mail, department, etc from active directory with the below PowerShell script:
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

#User Account to Sync and Site where the account exists
$UserAccount="Crescent\alex"
$WebURL="https://portal.crescent.com/projects/"

#Get the User's Current Display Name and E-mail
Get-SPUser -Identity $UserAccount -Web $WebURL | Select DisplayName,Email

#Force Sync from Active Directory
Set-SPUser -Identity $UserAccount -Web $WebURL -SyncFromAD

How to Re-Sync All users from Active Directory?
To resync all user details, use this PowerShell script:
Get-SPUser -Web http://web-app-url | Set-SPUser –SyncFromAD


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


SharePoint 2013: Update User's Display Name using PowerShell

Requirement:  I came across an issue where the user display name appeared as domain/username instead of First name Last name.

Solution: We observed, If the user profile sync is not properly configured or running, we'll face this issue! Other than UPS solution, You can use PowerShell to update user's display name.
change user display name in sharepoint 2013
PowerShell to change user display name in SharePoint 2013:
How to change the SharePoint user display name with PowerShell? Well, You can use Set-SPUser cmdlet.  Just provide the account identity, site and the new display name for user user.

Run this PowerShell cmdlet from SharePoint Management Shell.
Set-SPUser -Identity "i:0#.w|Crescent\Salaudeen" -DisplayName "Salaudeen Rajack" `
           –Web http://intranet.crescent.com
sharepoint powershell change user name
Sync User Account Details such as Display Name, E-mail, Department from Active Directory:
Sometimes, user account details may be updated in AD but not synced in SharePoint. If that's the case, you can force sync user account details such as display name, E-mail, department, etc from active directory with the below PowerShell script:
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

#User Account to Sync and Site where the account exists
$UserAccount="Crescent\alex"
$WebURL="https://portal.crescent.com/projects/"

#Get the User's Current Display Name and E-mail
Get-SPUser -Identity $UserAccount -Web $WebURL | Select DisplayName,Email

#Force Sync from Active Directory
Set-SPUser -Identity $UserAccount -Web $WebURL -SyncFromAD

How to Re-Sync All users from Active Directory?
To re-sync all user details, use this PowerShell script:
Get-SPUser -Web http://web-app-url | Set-SPUser –SyncFromAD

Update User's Display Name for All sites:
Get-SPSite -Limit All | Get-SPWeb | Foreach-object {
  Set-SPUser -Identity "i:0#.w|Crescent\Salaudeen" -DisplayName "Salaudeen Rajack" –Web $_ } 


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


Saturday, May 9, 2015

Check In All Documents in a SharePoint Library using PowerShell

Requirement: Check-in All files which are checked out in a SharePoint document library.

How to Check In all checked out documents in SharePoint 2013:
SharePoint 2013 makes it simpler by providing context sensitive ribbon buttons to check in multiple files in bulk. Simply select all files which are checked-out and click on "Check In" button from the ribbon.
check in multiple documents in SharePoint 2013
But this method doesn't work when you have any required field with no default value assigned!

Check In All Documents in a SharePoint Library using PowerShell
When you do Multiple file upload (bulk upload or through explorer view) and your required column doesn't has any default value in it, then your files will be checked-out automatically. The "Check In" button won't work when you miss-out any required fields in the library.
You must fill out all required properties before checking in this document.

So, our solution is: PowerShell.

PowerShell script to check in all documents in the library:
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

#Variables for Site URL and Library Name
$WebURL="http://sharepoint.crescent.com/sites/sales"
$LibraryName="Proposal Documents"

#Get Site and Library
$Web = Get-SPWeb $WebURL
$DocLib = $Web.Lists.TryGetList($LibraryName)

#Get all Checked out files
$CheckedOutFiles = $DocLib.Items | Where-Object { $_.File.CheckOutStatus -ne "None"} 

#Check in All Checked out Files in the library
ForEach($item in $CheckedOutFiles)
    { 
        #If you want to update fields
        #$item["Field"] = "value"
        #$item.SystemUpdate()

        #check in file programmatically     
        #$item.TakeoverCheckout() 
        $DocLib.GetItemById($item.Id).file.CheckIn("Checked in by Admin") 
        write-host "File:'$($item.Name)' has been checked in!"         
    }

Its possible to check-in file without supplying required field values through PowerShell!

If you want to do this for all libraries in your entire SharePoint web application, use: Find All Checked Out Files and Check-In them Back


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


Sunday, May 3, 2015

Start SharePoint User Profile Synchronization using PowerShell

To start user profile Synchronization manually:
  • Go to SharePoint Central Administration >> Application Management >> click Manage service applications.
  • On the Manage Service Applications >> click in the Name column of the User Profile Service Application
  • In Manage Profile Service page >> Under Synchronization section, click Start Profile Synchronization.
  • select either Start Incremental Synchronization (To Sync profiles that are changed since the last synchronization), or select Start Full Synchronization to synchronize all profiles
How to change the schedule of incremental sync:
By default, It runs once per day. You can schedule User Profile Incremental Synchronization from:
  •  User Profile Service Application 
  • Click on "Configure Synchronization Timer Job" under Synchronization 
  • Adjust the schedule accordingly
    Schedule SharePoint User Profile Synchronization using PowerShell
Start SharePoint User Profile Synchronization using PowerShell
If you want to do Full import once in a while (say, Weekly!), You can schedule this PowerShell script in Task scheduler. 
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

#Full Import Flag
$FullImport = $true

#Get User Profile Service Application
$UserProfileService = Get-SPServiceApplication | where { $_.TypeName -eq "User Profile Service Application" }

#Start Importing User Profile Sync
$UserProfileService.StartImport($FullImport) 


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...