Monday, March 30, 2015

Required Field Validation Based on Another Column's Value in SharePoint 2013

Requirement: In a custom SharePoint 2013 list, User's requirement is to validate a required field based on another field's value.

E.g. In a "Project Cost" list, user must fill "Budget Amount" field value if "Budget Approved" field's value is set to "True".

Solution: Here is how to implement a required field validation based on other column's value in SharePoint 2013.
  • Head on to List Settings
  • Click on "Validation settings" under "General Settings"
  • Enter the validation formula as: =IF([Budget Approved?]=TRUE,IF([Budget Amount]="",FALSE,TRUE),TRUE)
  • Enter the user (error) message accordingly. I've entered "If Budget is approved, you must specify the value of Budget Amount!".sharepoint 2013 required field validation
  • Click "OK" to save your changes
and the result in action:
Required Field Validation Based on Another Column's Value in SharePoint 2013

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


Export "User Information List" to Excel in SharePoint

At one point of time, I needed to export all users of a site collection to Excel and my trick to export user information list to excel as follows:

Export user information list to excel in SharePoint 2013:
Follow these steps to export user information list.
  • Navigate to Site Settings >> People and Groups. Now your browser URL should be something like: "http://SHAREPOINT-SITE.com/_layouts/15/start.aspx#/_layouts/15/people.aspx?MembershipGroupId=22". Just replace the value for "MembershipGroupId" to "0" to get "All People" view which lists all users of the site (which is nothing but "User Information List").
  • From here, Get the GUIDs of your User Information List and view. Here is How to Get the GUID of SharePoint list or View.
  • Replace "List GUID" and "View GUID" of yours in this URL and copy-paste it in the browser:
    http://SHAREPOINT-SITE-URL.com/_vti_bin/owssvr.dll?CS=109&Using=_layouts/query.iqy&List={LIST-GUID}&View={VIEW-GUID}&CacheControl=1
  • Navigate to the above URL, it should open the query, launch Microsoft Excel and Import all users from User Information List to Excel!
Alternate method:
Export User Information List to CSV using PowerShell:
Add-PSSnapin Microsoft.SharePoint.PowerShell –ErrorAction SilentlyContinue

#Variables
$SiteUrl="http://intranet.crescent.com"
$OutPutFile = "C:\UserInfoList.csv" 

#Get Web and User Information List
$web = Get-SPWeb $siteUrl
$UserInfoList = $Web.Site.RootWeb.Lists["User Information List"]

#Array to Hold Result - PSObjects
$ListItemCollection = @()
 
 #Get All List items where Status is "In Progress"
 $UserInfoList.Items | foreach {
 $ExportItem = New-Object PSObject 
 $ExportItem | Add-Member -MemberType NoteProperty -name "User Name" -value $_["Name"]
 $ExportItem | Add-Member -MemberType NoteProperty -Name "Department" -value $_["Department"]
 $ExportItem | Add-Member -MemberType NoteProperty -name "Job Title" -value $_["Job Title"]
 $ExportItem | Add-Member -MemberType NoteProperty -name "About Me" -value $_["About Me"]
 
 #Add the object with property to an Array
 $ListItemCollection += $ExportItem
 }
 #Export the result Array to CSV file
$ListItemCollection | Export-CSV $OutPutFile -NoTypeInformation  
Write-host "User Information List Exported to $($OutputFile) for site $($SiteURL)"

$web.Dispose()

This exports all users and groups of the site collection to CSV file.



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


Import Users from Excel (CSV) to SharePoint using PowerShell

Requirement: Got bunch of users and want to add them in to SharePoint? To bulk add users to SharePoint group programmatically using PowerShell, use the below script. This script Imports list of users from Excel .CSV file to SharePoint and adds them into appropriate groups.

Solution: Lets import users from Excel to SharePoint using PowerShell. Here is my CSV file with list of users and their target groups in SharePoint:
sharepoint import users from excel csv

PowerShell script to Import users from CSV to SharePoint 2013:
Add-PSSnapin Microsoft.SharePoint.PowerShell –erroraction SilentlyContinue

#Variables
$UserListCSV = "C:\UsersToImport.csv"
$SiteURL ="http://Sales.Crescent.com"

# Import the CSV file
$UserList = Import-CSV $UserListCSV #-header("GroupName","UserAccount") - If CSV doesn't has headers

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

#Iterate through each user from CSV file
foreach ($user in $UserList)
{
    #Get the Group and User
    $Group = $web.SiteGroups[$User.GroupName]
    $User = $web.Site.RootWeb.EnsureUser($User.UserAccount)
    #Add user to Group
    $Group.AddUser($User) 

    Write-Host "$($User) Added Successfully!" -ForegroundColor Green
}

#Dispose web object
$Web.Dispose()

Import Bulk Users to SharePoint site from CSV file using PowerShell:
My another CSV file has AccountName (in the format of: Domain\UserName and GroupName). 
add user to group powershell sharepoint 2010
PowerShell script to add user to SharePoint group:
Let's add a bit of error handling this time.
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

#Import the List of Users from a .csv file,
$UserList= Import-CSV "C:\UserList.csv"
 
#Get the Web
$web = Get-SPWeb "http://sharepoint.crescent.com/sites/marketing"
 
foreach ($Row in $UserList)
{
  #Get the Group
   $Group = $web.Groups[$Row.GroupName]
 
 #Validate the user name
 try
   {
        $user = $web.Site.RootWeb.EnsureUser($Row.AccountName)
   }
   catch [system.exception]
   {
     write-host $_.Exception.Message
   }
 
   #Add user if valid user name is provided
    if($user -ne $null)
    {
       $Group.AddUser($user)
       write-host $user.AccountName
    }
}

#Dispose the web object
$Web.Dispose()


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


Sunday, March 29, 2015

Create Managed Metadata Service Application (MMS) in SharePoint 2016 using PowerShell

Managed Metadata Service allows us to Centrally manage enterprise level metadata & Content Types to use between Site Collections, Web Applications even across farms. Creation of Managed Metadata Service in SharePoint 2016 provides us "Term Store" which is a central repository to manage Terms. The Term Store allows administrators to add/update/delete Term Sets, Term Groups, and Terms.

Use the below PowerShell script to add new managed metadata service application in SharePoint 2016. Change the configuration parameter values such as: Service Application name, application pool, database name, etc. accordingly.
Prerequisites: Create the content type hub prior creating Managed Metadata service application. Refer: Create Content Type Hub in SharePoint 2013
PowerShell Script to Create Managed Metadata Service Application in SharePoint 2013:
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
  
#Configuration Parameters
$ServiceAppName = "Managed Metadata Service Application"
$ServiceAppProxyName = "Managed Metadata Service Application Proxy"
$AppPoolAccount = "Crescent\SP16-AppPool"
$AppPoolName = "Service Application App Pool"
$DatabaseServer ="SP16-SQL001"
$DatabaseName = "SP16_Service_MMS"
$ContentTypeHub="http://intranet.crescent.com/ctypehub"
 
Try {
    #Set the Error Action
    $ErrorActionPreference = "Stop"
  
    #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 Service Account..."
        $AppPoolCredentials = Get-Credential $AppPoolAccount
        $AppPoolAccount = New-SPManagedAccount -Credential $AppPoolCredentials
    }
  
    #Check if the application pool exists already
    Write-Host -ForegroundColor Yellow "Checking if the Application Pool already exists"
    $AppPool = Get-SPServiceApplicationPool -Identity $AppPoolName -ErrorAction SilentlyContinue
    if ($AppPool -eq $null)
    {
        Write-Host -ForegroundColor Green "Creating Application Pool..."
        $AppPool = New-SPServiceApplicationPool -Name $AppPoolName -Account $AppPoolAccount
    }
  
    #Check if the Service application exists already
    Write-Host -ForegroundColor Yellow "Checking if Managed Metadata Service Application exists already"
    $ServiceApplication = Get-SPServiceApplication -Name $ServiceAppName -ErrorAction SilentlyContinue
    if ($ServiceApplication -eq $null)
    {
        Write-Host -ForegroundColor Green "Creating Managed Metadata Service Application..."
        $ServiceApplication =  New-SPMetadataServiceApplication -Name $ServiceAppName –ApplicationPool $AppPoolName –DatabaseName $DatabaseName –DatabaseServer $DatabaseServer 
    }
    #Check if the Service application Proxy exists already
    $ServiceAppProxy = Get-SPServiceApplicationProxy | where { $_.Name -eq $ServiceAppProxyName}
    if ($ServiceApplication -eq $null)
    {
        #Optional Parameters: 
        $ServiceApplicationProxy = New-SPMetadataServiceApplicationProxy -Name $ServiceAppProxyName -ServiceApplication $ServiceApplication -DefaultProxyGroup -ContentTypePushdownEnabled -DefaultKeywordTaxonomy -DefaultSiteCollectionTaxonomy -HubUri $ContentTypeHub
    }
    #Start service instance 
    $ServiceInstance = Get-SPServiceInstance | Where-Object { $_.TypeName -eq "Managed Metadata Web Service" }
 
    #Check the Service status
    if ($ServiceInstance.Status -ne "Online")
    {
        Write-Host -ForegroundColor Yellow "Starting the Managed MetadataService Instance..."
        Start-SPServiceInstance $ServiceInstance
    }
  
    Write-Host -ForegroundColor Green "Managed Metadata Service Application created successfully!"
}
catch {
    Write-Host $_.Exception.Message -ForegroundColor Red
 }
 finally {
    #Reset the Error Action to Default
    $ErrorActionPreference = "Continue"
 }
and here is the result of the above PowerShell script to create managed metadata service application:
You can use the optional parameters such as the URL for the content type hub from which the service application will consume content types.

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


Saturday, March 21, 2015

How to Update User Email Address in SharePoint using PowerShell

Problem:
SharePoint workflows failed because, user has no email address!
sharepoint change user email address
Solution is simple! SharePoint user has no email address, so add email address to users to resolve the issue!

How to update SharePoint user email address?
To update user email address, Use, Set-SPUser cmdlet. Here are some examples:
Syntax:
Set-SPUser -Identity "i:0#.w|Domain\username" -Email "email@domain.com" -Web http://sharepoint-site-url
Example:
Set-SPUser -Identity "i:0#.w|Crescent\Salaudeen" -Email "Salaudeen@crescent.com" -Web http://intranet.crescent.com/
This sets the Email ID of the user to given Email for entire site collection.

Change user email address from Active Directory:
You can Sync User's Email ID from Active Directory
Set-SPUser -Identity "i:0#.w|Domain\username" -Web "http://sharepoint-site-url" -SyncFromAD

Set-SPUser -Identity "i:0#.w|Crescent\Salaudeen" -Web "http://intranet.crescent.com/" -SyncFromAD
This script syncs user propoerties such as Display Name, Email, Department, etc from Active directory. Here is the result of updated user Email:
update user email in sharepoint

PowerShell script to update User Email address for all Sites in the web application:
Use this script to update user's Email address for the entire web application.
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
 
$WebAppURL="http://intranet.crescent.com"
$UserAccount="i:0#.w|Crescent\Salaudeen"

#Update Email for all sites in the web application
Get-SPWebApplication $WebAppURL | Get-SPSite -Limit All | Foreach-object {
    
    Write-host "Processing:" $_.Rootweb.URL

    #Get the User's Current Display Name and E-mail
    $User = Get-SPUser -Identity $UserAccount -Web $_.Rootweb.URL

    if($User -ne $null)
    {
        Set-SPUser -Identity "i:0#.w|Crescent\Salaudeen" -Email "Salaudeen@crescent.com" –Web $_.Rootweb.URL
    }
}


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


Thursday, March 19, 2015

Increase SharePoint Search Index File Size Limit

Problem: There are many Design documents uploaded to a SharePoint 2010 document library in Microsoft Word format in a Team site. Users reported these documents aren't appearing in search result.

Same time found in crawl logs: "This item was partially parsed. The item has been truncated in the index because it exceeds the maximum size." error.

Root cause: This is because SharePoint search crawler doesn't index large files > 16 MB by default! (in SharePoint 2010. For SharePoint 2013 & 2016, its 64 MB) Confirmed that the documents uploaded are about 20MB each! So SharePoint crawls only the meta data associated with the document and skips the contents inside the file!

Solution: Increase SharePoint search index file size limit
Add-PSSnapin Microsoft.SharePoint.Powershell -ErrorAction SilentlyContinue

$SSA = Get-SPEnterpriseSearchServiceApplication
#Get the current size
$SSA.GetProperty("MaxDownloadSize")

#Increase maximum file size in Crawl - indexer
$SSA.SetProperty("MaxDownloadSize", 100)
$SSA.Update()
This will increase the maximum size of files to index to 100 MB. Restart Search Service for the changes to take effect and Run a Full Crawl! You can also set maximum size for specific file type. E.g. MaxDownloadSizeExcel.

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


Tuesday, March 17, 2015

Set Default Home Page in SharePoint 2013

Its a common requirement in SharePoint 2013 to change its home page to some customized ones. In SharePoint 2013, to set homepage these options are available:

Change default home page on SharePoint 2013 Team sites:
  •  Navigate to your desired page
  • Click on "Page" tab, Click on "Make Homepage" button from the ribbon.
    sharepoint 2013 set homepage
  • Confirm to the "If you make this page the home page for this site, users will no longer be able to see the old site home page. Do you want to set this page as this site's home page?" message box.
    sharepoint 2013 default home page
  • Done!

SharePoint 2013 set default home page on Publishing sites:
The above method works for Publishing sites also. However, there is an another method too!
  • Navigate to site settings >> Click on "Welcome Page"
    link under "Look and Feel" sectionsharepoint 2013 change home page
  • Enter the home page URL either directly or by Clicking on "Browse" button and choosing the right page.
    sharepoint 2013 default home page
  • Click on "Ok" to save your changes.
Using SharePoint Designer to to change home page in SharePoint 2013
To change home page in SharePoint 2013 with SharePoint designer, follow these steps:
  • Navigate to "Site Pages" library, or any other library where your target page exists
  • Right click on the page and choose "Set as Home page" menu item from the context menu. Alternatively, you can use the Ribbon button also as highlighted.
    sharepoint 2013 edit home page
Set home page programmatically in SharePoint 2013:
If you want to set home page programmatically, Here is the code:

Change Home page using PowerShell:
Add-PSSnapin Microsoft.SharePoint.PowerShell –ErrorAction SilentlyContinue

#Variables
$WebURL="http://intranet.crescent.com"
$HomePageURL="SitePages/default.aspx"

#Get the Web
$web = Get-SPWeb $WebURL
 
#Change Welcome page
$RootFolder = $Web.RootFolder
$RootFolder.WelcomePage = $HomePageURL
$RootFolder.Update()
  
$web.Dispose() 

Related post: How to Set Welcome Page Programmatically in SharePoint

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


Monday, March 16, 2015

Configure Resource Throttling in SharePoint 2013 using PowerShell

What is Resource throttling?
Large lists are always performance killers in SharePoint. Luckily starting from SharePoint 2010, There is a feature called "Throttling" introduced to address this issue. 

Any operation such as data retrieval, update, delete of more than 2000 rows results low performance in SharePoint 2007 days. Throttling defines the Maximum number of rows user can query at a time. Any operation beyond this count displays an error message. The default value for this setting in SharePoint 2010 is 5000.

We manage resource throttling settings in SharePoint 2013 by navigating to:
  • Central Administration >> Manage Web Applications >> select the target web application
  • From the ribbon, Click on General settings >> Resource Throttling

Configure List throttling settings with PowerShell:
Use the below script to configure resource throttling settings for SharePoint 2013 using PowerShell
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

#Function to set Resource throttling values in SharePoint 2013
Function Set-ResourceThrottling
{
param (
[parameter(Mandatory=$true)] [string]$WebAppURL,

[parameter(Mandatory=$true)] [string]$ListViewThreshold,

[parameter(Mandatory=$true)] [boolean]$AllowOMOverride,

[parameter(Mandatory=$true)] [string]$ListViewThresholdForAdmins,

[parameter(Mandatory=$true)] [string]$MaxLookupFields
)

#Get the Web Application
$WebApp = Get-SPWebApplication $WebAppURL

#Set List View Threshold 
$WebApp.MaxItemsPerThrottledOperation = $ListViewThreshold

#Enable Object Model Override
$WebApp.AllowOMCodeOverrideThrottleSettings= $AllowOMOverride

#Set List View Threshold  for Admins
$WebApp.MaxItemsPerThrottledOperationOverride = $ListViewThresholdForAdmins

#Set List View Lookup Threshold
$WebApp.MaxQueryLookupFields = $MaxLookupFields #List View Lookup Threshold

$WebApp.Update()

Write-Host "Throttling settings has been updated on" $WebApp.URL
}

#Call the function to configure resource throttling values
Set-ResourceThrottling "http://intranet.crescent.com" "6000" $true "25000" "10" 

Enable/Disable Throttling at List level:
We can't set throttling limits on specific SharePoint list or library. But we can disable/enable throttling on it. Here is my PowerShell script to disable resource throttling on a particular list: Disable list throttling to access large lists in SharePoint 2010/2013

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


Saturday, March 14, 2015

How to Disable "Open with Explorer" View in SharePoint 2013

Requirement: Got a requirement to Hide "Open with Explorer" button from a particular library's ribbon menu due to some security reasons.

Solution: Open with Explorer button can be disabled in multiple approaches.
  1. Disable "Client Integration" from Web Application's Authentication Providers.
  2. Remove permissions "Use Remote Interfaces" which also removes "Use Client Integration Features" from permission levels.
  3. Edit the "CustomDefalutTemplates.ascx" file located at: C:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\TEMPLATE\CONTROLTEMPLATES. Find and Replace PermissionString from "UseClientIntegration" to PermissionString="MangeWeb" of nodes with ID "OpenInExplorer"
  4. CSS/JavaScript-jQuery methods to Turn-Off explorer view.
  5. Create a custom action with EMPTY CommandUIDefinition, so that it overrides existing ribbon button.
Lets stick with the last one!

Add Custom Action to Hide Open with Explorer:
While any ribbon button, group, tab can be hidden by overriding the specific custom action using Visual Studio based solution as in How to Hide SharePoint 2010 Ribbon Button, Group, Menu, Tab, Here I'm using PowerShell to add/remove custom action to hide Open with Explorer view in SharePoint 2013.
disable open with explorer in sharepoint 2013
Add custom action to disable Open with Explorer button in SharePoint 2013:
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

#Variables
$SiteUrl="http://operations.crescent.com/Monitoring" 
$ListName = "2015 Documents"

#Get Web and List objects
$web = Get-SPWeb $SiteURL
$list = $web.Lists[$ListName]

#Add an empty Custom Action to Override default custom action
$CustomAction = $list.UserCustomActions.Add()

$CustomAction.Title = "Hide Explorer View"
$CustomAction.Location = "CommandUI.Ribbon"
$CustomAction.commandUIExtension = "
            <CommandUIExtension> 
               <CommandUIDefinitions> 
                     <CommandUIDefinition 
                             Location='Ribbon.Library.Actions.OpenWithExplorer' /> 
                     </CommandUIDefinitions>
              </CommandUIExtension>" 

$CustomAction.Update();

write-host "Custom Action has been Added successfully!" 
and our Output! hide open with explorer button in SharePoint 2013
Delete the custom action from list:
Lets remove the custom action we've created to hide Open with Explorer button.
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

#Variables
$SiteUrl="http://operations.crescent.com/Monitoring" 
$ListName = "2015 Documents"
$CustomActionTitle = "Hide Explorer View"

#Get Web and List objects
$web = Get-SPWeb $SiteURL
$list = $web.Lists[$ListName]

#Get the custom action
$CustomAction = $list.UserCustomActions | where {$_.title -eq $CustomActionTitle} 

#Delete the custom action from list
if ($CustomAction)
{
    $CustomAction.Delete()
}

You can also remove a custom action from SharePoint list via SharePoint designer, as in below screen:
remove custom action from sharepoint designer 2013

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


How to Add Calculated Column to SharePoint List using PowerShell

Requirement: Add new Calculated field to SharePoint list programmatically using PowerShell script.

PowerShell to add calculated column in SharePoint list or library:
Add-PSSnapin Microsoft.SharePoint.PowerShell –ErrorAction SilentlyContinue

#Variables
$WebURL="http://projects.crescent.com"
$ListName="Proposal Documents"
$CalculatedColumnName="Created Month-Year"

#Get the Web
$web = Get-SPWeb $WebURL
 
#Get the List
$list = $web.Lists.TryGetList($ListName)
 
#Add new calculated column
$list.Fields.Add($CalculatedColumnName, "Calculated", $false)

#Get the column
$CalculatedCol = $List.Fields.GetField($CalculatedColumnName)
#Set Formula for calculated column 
$CalculatedCol.Formula='=TEXT(Created,"mmm-YYYY")'
$CalculatedCol.OutputType="Text"
$CalculatedCol.Update()
  
$web.Dispose() 

Script in action: Create calculated column in SharePoint 2013 using PowerShell
create calculated column 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.
*Sponsored


Tuesday, March 10, 2015

How to Recover Deleted Files (Documents / List Items) from Recycle Bin in SharePoint 2013

Ever wonder how to restore a deleted file in SharePoint? Like Windows, We've "Recycle Bin" feature in SharePoint. If you have Contributor permission or more, You can restore your deleted files.

Usually, files in Recycle Bins gets deleted permanently after 30 days. SharePoint 2013 uses two-stages of recycle-bins:
  1. End-User Recycle Bin - Files deleted goes here first. If deleted from here, its moved to "Administrator Recycle bin". You'll see all files deleted by you here.
  2. Administrator Recycle Bin - Site-collection administrator have access to it.
How to Restore Deleted Files in SharePoint 2013:
Follow these steps to recover deleted documents in SharePoint 2013.
  • Go to your SharePoint site Home page, Click on Settings icon at the top right corner of the SharePoint site and select Site Contents.to recover a deleted file in sharepoint 2013
  • In the "Site Contents" Page, Click on "Recycle Bin" link
    recover deleted file sharepoint document library
  • Select desired files to restore and click on "Restore Selection" link. Click "OK" button to Confirm the restore confirmation prompt.
    recover deleted file from sharepoint 2013
That's All!

How to Access Administrator Recycle Bin in SharePoint 2013:
You must have site collection Administrator access rights to get Admin Recycle bin.
  • Go to site settings page >> Recycle bin under Site Collection Administration
where you will get the End user Recycle Bin and Items Deleted from End User Recycle Bin.

Related Post: SharePoint Recycle Bins - Lets get it Crystal Clear

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


Monday, March 9, 2015

Find All Large Lists Exceeding Threshold Limit in SharePoint using PowerShell

Requirement: Find all lists exceeding the list view threshold limit configured on Web Application's resource throttling settings.

PowerShell Script to find all Large Lists which are exceeding the configured threshold limit:
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

#Get All Web Applications
$WebAppsCollection = Get-SPWebApplication

#Array to Hold Result - PSObjects
$LargeListsResult = @()

foreach($WebApp in $WebAppsCollection)
{
    #Get the Throttling Limit of the Web App
    $Threshold = $WebApp.MaxItemsPerThrottledOperation

    foreach($Site in $WebApp.Sites)
    {
        foreach($Web in $Site.AllWebs)
        {
            Write-host "Scanning site:"$Web.URL
            
            foreach($List in $Web.Lists)
            {
                if($list.ItemCount -gt $Threshold)
                {
                    $Result = New-Object PSObject
                    $Result | Add-Member NoteProperty Title($list.Title)
                    $Result | Add-Member NoteProperty URL($web.URL)
                    $Result | Add-Member NoteProperty Count($list.ItemCount)
                    
                    #Add the object with property to an Array
                    $LargeListsResult += $Result
                }
            }
        }
    }
}
Write-host "Total Number of Large Lists Found:"$LargeListsResult.Count -f Green

#Export the result Array to CSV file
$LargeListsResult | Export-CSV "c:\LargeListData.csv" -NoTypeInformation        

This script generates a CSV file at "C:\LargeListData.CSV", Just open it in Microsoft Excel, apply some formatting and here is how the report looks like:
get large lists report in sharepoint using powershell


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


Hide "Focus on Content" Full Screen Button in SharePoint 2013

Requirement: Hide Focus on Content button in SharePoint 2013!

As the name suggests, Focus on content button in SharePoint 2013 removes left & top navigation and lets you to focus on the site content once you click on it. In case you want to remove that button, here is the trick:
sharepoint 2013 remove focus on content full screen button

Solution: Hiding focus on content in SharePoint 2013 can be done with CSS. Simply follow these steps to hide focus on content in SharePoint 2013: Go to your target page, Edit and Add a script editor web part, insert the below CSS in it.

<style>
Span#fullscreenmodebox
{
 display:none;
}
</style>

You can also place the above CSS code in your Master page to hide focus on content button in SharePoint 2013.

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


Increase SharePoint 2013 Lookup Column Width

Requirement: Increase SharePoint 2013 multi-lookup field width

Solution: Use CSS styles to set lookup field width in SharePoint! Here is how:
  • Navigate to: http://your-sharepoint-site.com/Lists/Your-List/editform.aspx
  • Click on "Site Settings" gear >> Edit Page
  • Click on "Add Web Part" link and then choose "Script Editor "from "Media and Content" group
  • Click on "Edit Snippet" link script editor and Paste the below CSS in it. Save and close the page.
<style>
.ms-formtable table.ms-long {
    width:600px !important;
}

.ms-formtable table.ms-long .ms-input>select {
    width:300px !important;
}
</style>

Before:
sharepoint lookup column width
After:
sharepoint multi lookup field width



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


Sunday, March 8, 2015

How to Update List Items in SharePoint using PowerShell

How to Update List Items in SharePoint using PowerShell Script? Well, the basic syntax for updating a list item goes as:
#Get Web and List 
$Web = Get-SPWeb "http://sharepointsite.com"
$List = $Web.Lists["ListName"]

#Get the List item to update
$ListItem = $List.GetItembyID($ItemID)
 
#Set Column values
$ListItem["ColumnName"] = "New Value for the Field!"
 
#Update the Item, so that it gets saved to the list
$ListItem.Update()

Update SharePoint list item using PowerShell script
Lets take an another example:
Add-PSSnapin Microsoft.SharePoint.PowerShell -EA SilentlyContinue

$web = Get-SPWeb http://SharePointSite.com

#Get the Contacts List
$List = $web.Lists["Contacts"]

#Get the List Item by its Title field value
$ListItem = $List.Items | Where {$_["Title] -eq "Salaudeen Rajack"}

#Set "Department" column value
$ListItem["Department"] = "IT"

$ListItem.Update() 

Update All List items using PowerShell script:

$web = Get-SPWeb http://SharePointSite.com

#Get the Contacts List
$List = $web.Lists["Contacts"]

#Get All Items by update its title
$ListItems = $List.items
 
#Iterate through each item
foreach($Item in $ListItems)
{
    #Update the value of the "Title" column
    $item["Title"] = "Title Updated!"
 
    #Update the item
    $item.Update()
}

How about Updating Selective List Items in Bulk:
Lets update list item by its id field.
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

#Variables
$SiteURL = "https://portal.crescent.com/pipeline/"
$ListName = "Deals"

#Get the List
$List = (Get-SPWeb $SiteURL).Lists.TryGetList($ListName)

#List of Item IDs to update
$ItemIDs = 16,52,69,70,97,170,194,195,196,220,259

If($list)
{
    foreach($ItemID in $ItemIDs)
    {
        #Get Item by ID
        $ListItem = $List.GetItembyID($ItemID) 

        #Update List Item Fields
        $ListItem["Health and SafetyRisk"]="Low"
        $ListItem["Environmental Risk"]="Medium"
        $ListItem["Social Risk"]="High"       

        $ListItem.SystemUpdate()
        Write-host "Updated Item ID:"$ItemID
    }
}


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


Saturday, March 7, 2015

"Upgrade Required" Status in SharePoint 2013 Central Administration Servers in Farm

Getting "Upgrade Required" error message in SharePoint 2013? Well, Ideally, We have to run the SharePoint Products Configuration Wizard on the server(s) right after installing the service pack/patches.

In Windows Server 2012, SharePoint updates are part of Windows Server Update. It installs patches but never runs Products configuration wizard automatically! You still have to run psconfig wizard to complete patching!
sharepoint 2013 upgrade required error
SharePoint Patching is a two-step process:
  1. Install the patch binaries
  2. Run psconfig wizard manually.
Launch and run SharePoint configuration wizard to perform the configuration tasks. Once its finished, You should see  "No action Required" message in farm information status instead of upgrade required.
sharepoint 2010 central administration upgrade required
If you get any errors while running psconfig, the next step is to force SharePoint upgrade with this command line:
psconfig.exe -cmd upgrade -inplace b2b -force -cmd applicationcontent -install -cmd installfeatures

If you are using SQL aliases, make sure its configured in Every SharePoint server!

To apply patches on SharePoint 2013, Follow my step by step guide at: SharePoint 2013 Patching Guide - Step by Step

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


Monday, March 2, 2015

Find Who has Created a Site Collection, List or Library in SharePoint using PowerShell

If you want to find out who has created a SharePoint site, list or library: Sorry! There is no way from SharePoint user Interface!! You can't get "Created By" or "Created On" values anywhere. 

But PowerShell is our rescuer! Lets find who has created a SharePoint list using PowerShell:
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

#Get the List and Web
$web = Get-SPWeb "http://portal.crescent.com/sites/Sales"
$list = $web.lists["Sales Docs"]

#Get Creator and Created date of the given List
Write-host "List Created by:"$List.Author
Write-host "List Created on:"$List.Created

#Get Site collection Creator and Created Date 
write-host "Site Created by:"$web.Author
Write-host "Created on:" $web.Created 

Related post: Determine who created a list view in SharePoint

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