Tuesday, January 28, 2014

Usage and Health Data Collection Proxy Stopped in SharePoint 2013

Usage and Health Data Collection Service Application collects Data for Health Monitoring and usage Analytics Service. We found the Usage and Health Data Collection Proxy status in "Stopped" state, after deploying SharePoint 2013 to a new environment, from:
  • Central Administration >> Application Management 
  • Manage Service Applications Page
Usage and Health Data Collection Proxy Stopped in SharePoint 2013

Solution:
If you see Usage and Health Data Collection Proxy in "Stopped" state, you can start the Usage and Health Data Collection Proxy using these two lines of PowerShell Command:
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

$UsageAppProxy = Get-SPServiceApplicationProxy | Where {$_.TypeName -eq "Usage and Health Data Collection Proxy"}
$UsageAppProxy.Provision()
This should get your Usage and Health Data Collection Proxy started!

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


Sunday, January 26, 2014

Find SharePoint Site Column Usage - Report

When trying to delete a SharePoint site column, it gave me an alert saying "Site columns which are included in content types cannot be deleted.Remove all references to this site column prior to deleting it." 
sharepoint find field usage

Alright, Lets use PowerShell to find what lists or content types are using a particular site column, before deleting it.

PowerShell script to Find and delete a site column from Content type
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

$web= Get-SPWeb "http://sharepoint.crescent.com/sites/operations"
$ColumnInternalName = "BranchLocation"

#Get All Content Types
$CTypes = $web.site.rootweb.ContentTypes
foreach($ContentType in $CTypes)
 {
  $FieldInUse = $ContentType.FieldLinks | Where {$_.Name -eq $ColumnInternalName }
 
   if($FieldInUse -ne $null) 
   {
            Write-Host "Found the Column in Content Type:" $ContentType.Name -ForegroundColor DarkGreen
            #To Remove the field from content type, uncomment below two lines
                #$ContentType.FieldLinks.Delete($ColumnInternalName)
                #$ContentType.Update()
    }
 }

Done! Again when trying to delete the site column, received "This site column will be removed and all list columns which were created from it will be permanently orphaned. Are you sure want to delete this site column?"

sharepoint find site column usage

Well, What does it means? Site columns are created to minimize duplicates and to provide consistency. So, if we delete a site column, all list/library columns created will continue to hold their values. There will not be any impact on the data. But they'll become local columns. Alright, Before deleting a site column lets see where it s actually being used? Lets Find all references of our Site Column in a particular site collection using PowerShell.

PowerShell script to Find a Site column usage on Lists
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

#Site URL
$SiteURL = "http://sharepoint.crescent.com/sites/operations"
#Column to search
$ColumnInternalName = "BranchLocation"

#Get the Web
$Site = Get-SPSite $SiteURL
#Get the Column
$column = $site.RootWeb.Fields.GetFieldByInternalName($ColumnInternalName)

#Find all List usages of the column
$SiteColumnUsages = $column.ListsFieldUsedIn() #Gets the WebID & ListID values

#Get the lists where the site column is being used
foreach( $Usage in $SiteColumnUsages )
    {
        $Site.AllWebs | foreach {$_.Lists} | where {$_.ID –eq $Usage.ListID } | Select Title, ParentWebURL, RootFolder
    }
 
 Write-Host "Checking Lists to Remove the Site column..."
 foreach( $Usage in $SiteColumnUsages )
        {
 #Remove columns from Lists where its used 
   $List =  $Site.AllWebs | foreach {$_.Lists} | where {$_.ID –eq $Usage.ListID } 
      if($List.Fields.ContainsFieldWithStaticName($ColumnInternalName))
   {
    $field = $List.Fields.GetFieldByInternalName($ColumnInternalName)

    ## Uncomment these four lines to actually delete a site column from Lists
    #$field.AllowDeletion = $true
    #$field.Update()
    #$List.Fields.GetFieldByInternalName($ColumnInternalName).Delete()
    #$List.Update()
    Write-Host "Site column $($ColumnInternalName) has been removed from $($List.RootFolder) at $($List.ParentWeb.URL)"
   }
 } 
 


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 your SharePoint Library to "Favorites" in Windows

Here is a nifty trick to add your SharePoint library under "Favorites" section.
  • Open your SharePoint library in Explorer view
  • Right click on "Favorites" and choose "Add current location to favorites"
    Add SharePoint folder to Favorites
  • Alternatively, you can just drag and drop the folder icon from address bar to Favorites. This will add the current document library to Favorites menu.
If needed, you can rename it even. Once added, this location can be used from Open/Save dialog boxes!

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


Saturday, January 25, 2014

How to Upload a List Template in SharePoint 2013 using PowerShell

Requirement: Upload a custom list template to specific site collections in a web application. While upload a list template using from SharePoint web interface is simple, wanted to automate this process as its repeating for multiple site collections.

PowerShell to Upload list template in SharePoint 2013:
Here is the PowerShell script to upload custom list template to SharePoint site :
Add-PSSnapin Microsoft.SharePoint.Powershell -ErrorAction SilentlyContinue

Function Upload-ListTemplate($WebURL, $TemplateFilePath)
{
 #Get the Web
 $web = Get-SPWeb $WebURL
 #Get the List template Gallery Folder
 $TemplateFolder = $web.GetFolder("List Template Gallery") 
 #Get the Files collection
 $TemplateFileCollection = $TemplateFolder.Files
 #Get the Template file from Local File system
 $TemplateFile = Get-ChildItem $TemplateFilePath
 
 #Open the File in Read mode and Add to Templates collection 
    $TemplateFileCollection.Add("_catalogs/lt/$($TemplateFile.Name)", $TemplateFile.OpenRead(), $true)
 Write-Host "Done!Template has been uploaded!!"
}

 #Call the function to upload list template
 Upload-ListTemplate "http://intranet.crescent.com" "D:\Templates\CreditTemplate.stp"
You can verify the uploaded template by navigating to List template gallery: http://intranet.crescent.com/_catalogs/lt/Forms/AllItems.aspx
how to upload list template in sharepoint 2010 using powershell


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


Copy SharePoint List Column Values from One to Another

In some situations, we may have to copy SharePoint list column values from one column to another. Say, for E.g.
  • OOTB column doesn't provide a way to enter more than 255 characters in Multiple Lines of Text field. As user already entered values in it and wants to make it allow more than 255 chars.
  • When a SharePoint field's internal name needs to be changed.
  • There is requirement to add a new column, whose values are partially based on an existing column
While the Data Sheet view is one solution, Its not available for all lists. And even in datasheet view, some columns like people picker values can't be copy/pasted. So, the solution is: PowerShell

Here is the PowerShell script to copy SharePoint list / library field data from one column to another column:
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")

#Using Get-SPSite in MOSS 2007
function global:Get-SPSite($url)
 {
    return new-Object Microsoft.SharePoint.SPSite($url)
 }

Function global:Get-SPWeb($url)
{
  $site= New-Object Microsoft.SharePoint.SPSite($url)
        if($site -ne $null)
            {
               $web=$site.OpenWeb();
       
            }
    return $web
}
 
 #Parameters
 $web = Get-SPweb "http://sharepoint.crescent.com/"
 $listName = "Pictures"
 
 #Use the Display Names
 $CopyFromColumnName = "Description" #column copy source
 $CopyToColumnName = "Desc"  #destination column

  #Get the List
  $list = $web.lists[$ListName]

     #Get all Items  
     $Items = $list.Items

     foreach ($Item in $items)
        {
            #copy data from one column to another
            $item[$copyToColumnName] = $item[$copyFromColumnName]

            #Do a system update to avoid Version and to Keep same metadata
            $item.SystemUpdate($false)
        } 



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


Monday, January 20, 2014

How to Use RunWithElevatedPrivileges in PowerShell Scripts for SharePoint

We use RunWithElevatedPrivileges method to impersonate System Account (Application pool identity), which is granted with FULL control access rights via web application user policy. Here is an example of using RunwithElevatedPrivileges with PowerShell:

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
 
[Microsoft.SharePoint.SPSecurity]::RunWithElevatedPrivileges(
{

    #Define the parameter values: Site collection URL and user account to remove
    $siteURL =  "http://sharepoint.crescent.com/sites/sales"
    $userAccount = "crescent\Salaudeen" 
  
    #Get the RootWeb
    $web= Get-SPWeb $siteURL
    #Get the user acount - If doesn't exists ADD
    $user = $web.EnsureUser($userAccount)
 
    #Make the user as Site collection Admin
    $user.IsSiteAdmin = $true
    $user.Update()
 
    #Print a message
    Write-host "User: $($userAccount) has been added as site collection administrator!"   
 
 }
)  
This PowerShell example uses run with elevated privileges in SharePoint to add new site collection administrator.

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


SharePoint Rich Text Editor Toolbar Missing - Solution

User reported an issue: SharePoint rich text editor toolbar is missing on list columns!
SharePoint Rich Text Editor Toolbar Missing
I verified that the SharePoint list columns are enabled with "Rich Text" capabilities, but still rich text editor toolbars are missing!

Solution: Open SharePoint site in Internet Explorer 32 bit mode! Here is how: Type "Internet explorer" in Start menu, Choose "Internet Explorer" link as in the screen.


Here is the Rich text editor/multi-line column with rich text editing toolbar:


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


SharePoint 2010/2013 Search Query Suggestions

Search suggestions are one of the great new feature introduced in SharePoint 2010, enhanced in SharePoint 2013. Search query suggestions are words that appear under the search box as users type a Search query. (also known as: Pre-query suggestions).

SharePoint Search suggestions are automatically generated:
When users have clicked any of the search results for that query at least six times, then that query will be automatically added to search suggestions. Technically, on a daily basis, the SharePoint timer job titled "Prepare Query Suggestions" handles compiling them. So the automatic query suggestions can be different for different result sources and site collections.

Although Search query suggestions are auto populated based on user searches, It would be helpful to manually add search query suggestions to promote specific areas of your SharePoint. Isn't it?

How to Add SharePoint 2010 Search Suggestions using PowerShell:
Lets add SharePoint 2010 search suggestions with PowerShell script.

Add-PSSnapin "Microsoft.SharePoint.Powershell" -ErrorAction SilentlyContinue

    #Set the Terms to add in Search Suggestions
    $SearchSuggestions = @("Crescent", "Crescent Policies", "Crescent News", "Crescent Tech", "Crescent Employee Of the Month", "Crescent Travel Request")

    #Get the Search Service Application "Search Service Application" - Your's may be in different name
    $ssa = Get-SPEnterpriseSearchServiceapplication -Identity "Search Service Application" 

    #Process Each Search Term
    foreach ($Suggestion in $SearchSuggestions)
    {
        New-SPEnterpriseSearchLanguageResourcePhrase -SearchApplication $ssa -Language en-US -Type QuerySuggestionAlwaysSuggest -Name $Suggestion
    }

    #Trigger the Timerjob
    $timerJob = Get-SPTimerJob "Prepare query suggestions"
    $timerJob.RunNow()
Instead of having them in a hard-coded array, Its also possible to have them in a CSV file and import them:
$csvfile = "D:\SearchSuggestions.csv" #with header "Suggestion"
$KeyWordsData = Import-Csv $csvfile
...

foreach ($Row in $KeywordsData)
{
  New-SPEnterpriseSearchLanguageResourcePhrase -SearchApplication $ssa -Language en-US -Type QuerySuggestionAlwaysSuggest -Name $Row.Suggestion
}
...
You can get the Search service application name by navigating to central admin and manage service applications page.

SharePoint 2010 search query suggestions not working? Run the timer job: "Prepare Query Suggestions". Also, make sure SharePoint 2010 Show Query Suggestions option is enabled in search box web part properties!
sharepoint 2010 search query suggestions not working

 Result: As a user types keywords in the Search box, the Search Center provides suggestions to help complete the query
sharepoint 2010 search query suggestions

To Get all SharePoint 2013 search query suggestions:
#Get the Search Service Application "Search Service Application" by its name
$ssa = Get-SPEnterpriseSearchServiceapplication -Identity "Search Service Application" 
#Get all  Search Query suggestion
Get-SPEnterpriseSearchQuerySuggestionCandidates -SearchApplication $ssa

Remove a Search Suggestion using PowerShell:
Add-PSSnapin "Microsoft.SharePoint.Powershell" -ErrorAction SilentlyContinue

#Get the Search Service Application "Search Service Application" by its name
$ssa = Get-SPEnterpriseSearchServiceapplication -Identity "Search Service Application" 

#Remove Search Query Suggestion "Crescent Employee Of the Month"
Remove-SPEnterpriseSearchLanguageResourcePhrase -SearchApplication $ssa -Language En-Us -Type QuerySuggestionAlwaysSuggest -Identity "Crescent Employee Of the Month"

#Trigger the Timerjob for the changes to take effect
$timerJob = Get-SPTimerJob "Prepare query suggestions"
$timerJob.RunNow()

How to Add SharePoint 2013 search query suggestions manually:

Go to Central Administration >> Manage service applications >> Search Service Application >> Click on Query Suggestions link from left navigation. From here, you can enable/disable, Import/Export your custom search query suggestions.
sharepoint 2013 query suggestions

BTW, importing query suggestions overwrites any existing manual query suggestions created already! So, Export them first, modify and then import again!!

Whats new in SharePoint 2013 search query suggestions:
Things are slightly different in SharePoint 2013, as it allows customizing Search parameters at SSA/Site collection/Site level. So, We've an additional parameter "Owner" to specify the scope. Also, query suggestions have improved in SharePoint 2013 with result sources. The query suggestions are generated daily for each result source - each site collection.

Add-PSSnapin "Microsoft.SharePoint.Powershell" -ErrorAction SilentlyContinue

#Set the Terms to add in Search Suggestions
$SearchSuggestions = @("Crescent", "Crescent Policies", "Crescent News", "Crescent Tech", "Crescent Employee Of the Month", "Crescent Travel Request")

#Get the default search service application
$ssa = Get-SPEnterpriseSearchServiceApplication
#You can also use: Get-SPEnterpriseSearchServiceapplication -Identity "Search Service Application" 

$owner = Get-SPEnterpriseSearchOwner -level SSA

#Process Each Search Term
foreach ($Suggestion in $SearchSuggestions)
{
   New-SPEnterpriseSearchLanguageResourcePhrase -SearchApplication $ssa -Language En-Us -Type QuerySuggestionAlwaysSuggest -Name $Suggestion -Owner $owner
}
#Trigger the SharePoint 2013 query suggestions timer job
Start-SPTimerJob -Identity "Prepare query suggestions"
Don't forget to Run the SharePoint 2013 query suggestions timer job!

Remove Search Suggestions at SSA level in SharePoint 2013:
Add-PSSnapin "Microsoft.SharePoint.Powershell" -ErrorAction SilentlyContinue

#Get the default search service application
$ssa = Get-SPEnterpriseSearchServiceApplication

#Set the Query Suggestion Level
$owner = Get-SPEnterpriseSearchOwner -level SSA

#Get All Existing phrases
$SuggestionList = Get-SPEnterpriseSearchLanguageResourcePhrase  -SearchApplication $ssa -Owner $Owner -Language En-Us -Type QuerySuggestionAlwaysSuggest #-SourceId $ResultSource.Id

#Remove Them All
$SuggestionList |  Remove-SPEnterpriseSearchLanguageResourcePhrase -Type QuerySuggestionAlwaysSuggest -Language "en-us" -Owner $Owner 

#Trigger the SharePoint 2013 query suggestions timer job
Start-SPTimerJob -Identity "Prepare query suggestions"

Add Query Suggestions at Site Level in SharePoint 2013:
Add-PSSnapin "Microsoft.SharePoint.Powershell" -ErrorAction SilentlyContinue

#Set the Terms to add in Search Suggestions
$SearchSuggestions = @("Crescent", "Crescent Policies", "Crescent News", "Crescent Tech", "Crescent Employee Of the Month", "Crescent Travel Request")

#Get the default search service application
$ssa = Get-SPEnterpriseSearchServiceApplication

$Web = Get-SPweb -Identity "http://sharepoint.crescent.com/sites/operations/"

$owner = Get-SPEnterpriseSearchOwner -Level SPWeb -SPWeb $web 

$FederationManager  = New-Object Microsoft.Office.Server.Search.Administration.Query.FederationManager –ArgumentList $ssa

$ResultSource = $FederationManager.GetSourceByName("Local SharePoint Results", $owner)

#Process Each Search Term
foreach ($Suggestion in $SearchSuggestions)
{
   New-SPEnterpriseSearchLanguageResourcePhrase -SearchApplication $ssa -Language En-Us -Type QuerySuggestionAlwaysSuggest -Name $Suggestion -Owner $owner -SourceId $ResultSource.Id
}

#Its also  possible to use PowerShell to Import Search Suggestions from text file using PowerShell
#$ssap = Get-SPEnterpriseSearchServiceApplicationProxy
#Import-SPEnterpriseSearchPopularQueries -SearchApplicationProxy $ssap -Filename "D:\querySuggestions.txt" -ResultSource $source -Web $web

#Trigger the timer job
Start-SPTimerJob -Identity "Prepare query suggestions"
That is it you have added a query suggestion to your SharePoint searh box. Now you start typing SharePoint it will will bring SharePoint suggestion.
sharepoint search box query suggestions


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


Sunday, January 19, 2014

Find Top 10 Site Collections based on its Usage during Last Month

PowerShell Script to find top 10 SharePoint 2007 site collections based on its usage hits:

[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")

#Functions to Imitate SharePoint 2010 Cmdlets in MOSS 2007
function global:Get-SPWebApplication($WebAppURL)
 { 
  return [Microsoft.SharePoint.Administration.SPWebApplication]::Lookup($WebAppURL)
 }
 
function global:Get-SPSite($url) {
    return new-Object Microsoft.SharePoint.SPSite($url)
 } 
 
function global:Get-SPWeb($url) {
  $site= New-Object Microsoft.SharePoint.SPSite($url)
        if($site -ne $null) {
               $web=$site.OpenWeb();        
            }
    return $web
} 

#Get all site collections of the provided web application
$WebApp = Get-SPWebApplication "https://intranet.crescent.com"
$SitesCollection = $WebApp.Sites

$UsageDataCollection = @()
 #Iterate through each site collection
 ForEach($site in $SitesCollection)
 {
    $web = Get-SPWeb $site.URL
    $LastMonthUsage = ($web.GetUsageData("url", "lastMonth") | sort 'Total Hits')
    If($LastMonthUsage -ne $null)
 { 
  
     $totalHits = ($LastMonthUsage | Measure-Object 'Total Hits' -Sum | Select -expand Sum)     
        
        $UsageDataResult = New-Object PSObject
        $UsageDataResult | Add-Member -type NoteProperty -name "Site Collection URL" -value $site.URL
        $UsageDataResult | Add-Member -type NoteProperty -name "Site Title" -value $web.title
        $UsageDataResult | Add-Member -type NoteProperty -name "Total Hits" -value $totalHits

        $UsageDataCollection += $UsageDataResult

  #Clear variables
     $LastMonthUsage = $null
     $tHits = $null
    }
 }
 
 $UsageDataCollection | sort-object "Total Hits" -descending | select-object -first 10 | Export-csv "Top10Sites.csv" -notypeinformation
 
For SharePoint 2010 and above, Use Web Analytics Web Part!

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


Monday, January 13, 2014

Force Run SharePoint Health Analyzer Jobs on Demand

We may want to run SharePoint health analyzer on-demand to check if everything is alright in the farm, without waiting for them to run automatically. Well, as discussed in my another article, Run SharePoint 2010 Timer Jobs On-Demand with PowerShell , we can force run SharePoint Health Analyzer timer Jobs on Demand with PowerShell!

How to run SharePoint 2010/2013 health analyzer with PowerShell:
Lets use PowerShell to force run health analyzer jobs.
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
 
#Display name of the Timer Job to Run on-demand
$TimerJobName = "Health Analysis Job"
 
#Get the Timer Job
$TimerJobs = Get-SPTimerJob | where { $_.DisplayName -match $TimerJobName}

foreach($TimerJob in $TimerJobs) 
 {
    Write-Host "Running:" $TimerJob.DisplayName
    $TimerJob.RunNow()
 }
This script executes all timer jobs with "Health Analysis Job" in its display name which performs health check immediately!
Run SharePoint 2013 Health Analyzer Jobs on Demand

One Liner to SharePoint 2010/2013 run all health analyzer:
Get-SPTimerJob | where { $_.DisplayName -match "Health Analysis Job"} | % { Start-SPTimerJob $_ ; Write-Host "Runing Job:" $_.displayName } # 


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


How to Disable "I Like It" "Tags & Notes" in SharePoint 2010

'I Like it' and 'Tags and Notes' features are introduced in SharePoint 2010 to improve user collaboration, social communication capabilities and to enable users to provide their feedback on items, pages, etc. However, not all SharePoint environments requires this feature, so here are some ways to to remove "I like it" and "Tags & Notes" tag buttons from SharePoint 2010.
Removing "I Like It" and "Tag and Notes" from SharePoint Site
 
SharePoint 2010 disable "I Like It" "Tags and notes" at farm level:
If you want to remove "I like It" , "Tags & Notes" at farm level, follow these steps:
  • Go to Central Administration >> System Settings >> Click on "Manage Farm Features"  How to Remove the “I like it” and “Tag & Notes”
  • Deactivate "Social Tags and Note board Ribbon Controls"Hiding the social tags in SharePoint 2010
Or you can disable by PowerShell
Disable-SPFeature –Identity SocialRibbonControl

To enable, use:
Enable-SPFeature –Identity SocialRibbonControl
Microsoft KB to turn off the "I Like It" and the "Tags & Notes" features in SharePoint Server 2010: http://support.microsoft.com/kb/983263/en-US

While this change is instant and disables/enables social tags at farm level for all web applications, We can target this setting based on user group too. Here is how:

Disable social tagging permissions to specific users and groups:
You can also enable/disable social tagging feature for specific users or groups by removing them from the Use Social Features permission, which is part of the User Profile service application.
  • Go to Central Admin >> Click on Manage Service Applications
  • Pick your User Profile Service Application from the list
  • Click on "Manage User Permissions" link under People section
  • Select the user or group for which you want to turn off the "I Like It" and the "Tags & Notes" features.
  • Under Permissions, click to clear the Use Social Features check box. and click OK.SharePoint 2010: Disable "I like it" und "Tags and Notes"
It takes a minute (by a timer job!) and this setting is a cumulative (you remove permission from one group and you grant for one! Then the user will be able to see )
How to remove "I like it" and "Tags & Notes" from SharePoint 2010

You can also use my solution How to Hide SharePoint 2010 Ribbon Tab - Group - Button - Menu to disable/hide/remove "I Like It" tags on particular site/site collection. It actually uses the "CustomAction" feature to hide those buttons.

Hide I Like It Tags & Notes using CSS:
Use IE developer toolbar or Firebug in Firefox to get the ID/Class of the tags, and set its visibility to none.
sharepoint 2010 i like it feature remove Place this css code in your SharePoint 2010 Master page, or custom style sheet, wherever applicable.
/* SharePoint 2010 hide i like it tags & notes CSS code */
<style type="text/css">
.s4-socialdata-notif
{
  display:none;
}
</style> 

SharePoint 2010 remove i like it cCSS
Unlike the above requirement, you may have to disable i like it button alone with CSS. Here is the  code: 
/* sharepoint 2010 hide i like it css */
<style type="text/css">

#AddQuickTag_ctl00_ctl36 {
display:none;
}
#AddQuickTagImg_ctl00_ctl36 {
display:none;
}
</style>
SharePoint 2010 i like it disabled  
How about securing it : with SharePoint Security Trimmed Control? 
Edit your master page, Find:
<SharePoint:DelegateControl ControlId="GlobalSiteLink3" Scope="Farm" runat="server"/>
and move it inside:
<Sharepoint:SPSecurityTrimmedControl runat="server" Permissions="ManagePermissions">

   <SharePoint:DelegateControl ControlId="GlobalSiteLink3" Scope="Farm" runat="server"/>

</SharePoint:SPSecurityTrimmedControl>
You can even set style="display:none" for the above element in Master page to make it hidden. For all available permission strings, refer: http://msdn.microsoft.com/EN-US/library/ms412690

SharePoint 2010 i like it feature disabled?
"I Like It" not available in SharePoint 2010? those button missing? Here is how to enable "I Like it":
Check all of the above discussed things in reverse order! Additionally, Its depending on "User Profile " and "Managed Metadata Service Application", So make sure these SAs are up and running and associated via "Service connection" with the web application. You may get "Notes & Tags" alone, if you have only user profile service application configured and associated. (If you don't have UPSA, you won't see neither of them!)


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


Document Expiration Monitor - Automation with PowerShell Script

Requirement: There are bunch of document libraries with several documents loaded on various site collections. We've to monitor their expiry date based on a column and send e-mail notification to all members of  a  SharePoint Group. Also all E-mails sent should be logged in a tracking list.

Solution: Lets write a PowerShell script to scan required document libraries and send E-mail. BTW - Its for MOSS 2007 (But the script works on any SharePoint versions, of course!)

PowerShell Script:
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")

##################################################################################
##  VARIABLES SECTION ##
##################################################################################

$LibraryURLs = @("https://intranet.Crescent.com/sites/IT/docs/", "https://intranet.Crescent.com/sites/operations/inventory/", "https://intranet.Crescent.com/sites/Sales/documents")

### Variables for Email setup
#URL of the Site where the SharePoint group exists
$EmailGroupSite = "https://intranet.Crescent.com/sites/IT/"
#Name of the SharePoint Group to which emails to be sent
$EmailGroupName= "Report Group"

#Internal Name of the Column which stores the expiration date of documents
$ExpiryDateColumnInternalName = "Expiration_x0020_Date0"
#How to get the Internal name of a SharePoint Column? 
#Refer http://www.sharepointdiary.com/2011/06/sharepoint-field-display-name-vs-internal-name.html

#Site URL where the tracking list "Document Expiration Monitor - Tracking" to be maintained 
$TrackingSiteURL = "https://intranet.Crescent.com/sites/IT/"

$ExpiryDays = 7  

$SMTPServer = "smtp.Crescent.com"

$EmailFrom = "DocumentExpiryMonitor@YOURCOMPANY.com"
$EmailSubject = "Document Expiration Monitor Report as on $(Get-Date)"

#Region Functions
###############################################################################
##  FUNCTIONS ##
###############################################################################

#Functions for Get-SPSite & Get-Web in MOSS 2007
function global:Get-SPSite($url) {
    return new-Object Microsoft.SharePoint.SPSite($url)
 } 
 
function global:Get-SPWeb($url) {
  $site= New-Object Microsoft.SharePoint.SPSite($url)
        if($site -ne $null) {
               $web=$site.OpenWeb();        
            }
    return $web
} 

#Validate the Web at given URL
function Validate-Web($WebURL)
 { 
  try {
    $web = Get-SPWeb $WebURL
    return $web
      }
  catch {
    $Message = "Error in Site URL:$WebURL. Please provide valid Site URL!"
    Write-Host $Message -ForegroundColor red
    Append-LogMessage $Message $error[0]
    
    #Continue executing code
    continue
    
    return $null
   }
 }

#Validate the Web at given URL
function Validate-SPSite($SiteURL)
 { 
  try {
    $Site = Get-SPSite $SiteURL
    return $Site
      }
  catch {
    $Message = "Error in Site Collection URL:$SiteURL."
    Write-Host $Message -ForegroundColor red
    Append-LogMessage $Message $error[0]
    
    #Continue executing code
    continue
    
    return $null
   }

 }
#Function to validate given List URL 
 function Validate-List($ListURL)
 { 
  try {
    $list = $web.GetList($ListURL)
    return $list
      }
  catch {
    $Message = "Error in List URL: $ListURL! Please provide valid List URL!"
    Write-Host $Message -ForegroundColor red
    Append-LogMessage $Message $error[0]
    
    #Continue executing code
    continue
    
    return $null
   }
 }
 
function Send-Email ($EMailBody, $EmailTo) {
 try {
    #Send the Mail
    $MailMessageParameters = @{
   SmtpServer = $SMTPServer
      Subject = $EmailSubject 
      Body = $EmailBody 
      From = $EmailFrom 
      To =  $EmailTo 
      }
    Send-MailMessage @MailMessageParameters -BodyAsHtml
   Append-LogMessage "Email has been sent to :"$EmailTo
 }
 catch {
  Write-Host "Error sending email, Please check log file!" -ForegroundColor Red
  Append-LogMessage $error[0]
 }
}

#Function to Get the Location where script is located
function GetScriptDir
{
 $Invocation = (Get-Variable MyInvocation -Scope 1).Value
 return Split-Path $Invocation.MyCommand.Path
}

#Extract Emails from each user in a Group
function Get-GroupEmails()
{
 try {
  $Emails=@()
  $Site = Validate-SPSite $EmailGroupSite
   if($site -ne $null)
   {
    $Group = $site.RootWeb.sitegroups | Where {$_.Name -match $EmailGroupName}
    #$Group= $web.SiteGroups[$GroupName]   
    if($Group -ne $null)
    {     
     $Users = $Group.Users
        foreach ($User in $Users)
                 {
         if( ($user.Email -ne "") -and ($user.Email -ne $null) )
         { 
          $Emails+=$user.Email
         }
        }
      $Emails =  $Emails -split ","   
      return $Emails
    }
    else
    {
     $Message = "E-mail Group Name:$EmailGroupName Not found!"
     Write-Host $Message -ForegroundColor red
     Append-LogMessage $Message $error[0]
     return $null
    }
   }
  }
  catch {
    $Message = "Error in Get-GroupEmails Function!"
    Write-Host $Message -ForegroundColor red
    Append-LogMessage $Message $error[0]
    
    #Continue executing code
    continue
    
    return $null
   }  
  }

#Function to Log details to Tracking List
function LogTo-TrackingList($EmailBody)
{
 $web = Validate-Web $TrackingSiteURL
 if($web -eq $null) 
 {
  # Creating base file to append to, adding a new line for readability
  $Message = "Tracking Site URL is not valid!"
  Write-Host $Message -ForegroundColor Red
  Append-LogMessage $Message
  return
 } 
 
 #Try to Get the "Tracking List"
 $TrackingList = $web.Lists | Where { $_.Title -match "Document Expiration Monitor - Tracking"}
  
 #If Tracking list doesnt exist, Create it
 if($TrackingList -eq $null)
 {
  #Create New Tracking List
  $TrackingListID = $Web.Lists.Add("DEMTracking","List to Track Document Expiration Monitor Mails",[Microsoft.SharePoint.SPListTemplateType]::GenericList)
  #Set Name for the List
  $TrackingList = $web.Lists[$TrackingListID]
  $TrackingList.Title="Document Expiration Monitor - Tracking"
  $TrackingList.update()

  #Rename the "Title Field" to Tracking ID
  $TitleField = $TrackingList.Fields.GetFieldByInternalName("Title")
  #Set Field Display Name and Update
  $TitleField.Title ="Tracking Date"
  $TitleField.Update()

  #Add Email Body Field 
  $EmailBodyField = $TrackingList.Fields.Add("Email Body","Note",$true)
  $trackingList.Fields["Email Body"].RichText = $True
  $trackingList.Fields["Email Body"].RichTextMode = "FullHtml"
  $trackingList.Fields["Email Body"].update()

 }
    #Add New Item to Tracking List
    $item = $TrackingList.Items.Add()
    #Set the Tracking Date & Email Body field values
    $item["Email Body"] = $EmailBody 
     
    #Set the Tracking Date field
    $item["Tracking Date"] = $TodaysDate
    $item.update()
  
   #Log details to Tracking List
   $web.dispose()
 
}

# Appends text to the log message
function Append-LogMessage($text) 
{
 Add-Content $LogTextFileName $text"`r" -Encoding UTF8 
}

#EndRegion

#Variables for Internal processing
$ScriptPath = GetScriptdir

#Get the Template HTM File with CSS
$MailContent = Get-Content -Path "$ScriptPath\template.htm" -Encoding UTF7 | Out-String

$CAMLDateFormat = "yyyy'-'MM'-'dd'T'HH':'mm':'ss'Z'"
$DateFormat = "MM/dd/yyyy"

$TodaysDate = Get-date
$TodaysDateFormatted = (Get-date).ToString($CAMLDateFormat) 
$ExpirationDate = (Get-Date).AddDays($ExpiryDays)
$ExpirationDateFormatted = (Get-Date).AddDays($ExpiryDays).ToString($CAMLDateFormat) 
$LogTextFileName = "$ScriptPath\DEM_LOG.txt"
$Message =""

# Creating base file to append to, adding a new line for readability
$Message = "Script Execution Started at $TodaysDate." >> $LogTextFileName
Write-Host $Message -ForegroundColor DarkGreen
Append-LogMessage $Message

###############################################################################
##  PROCESS EACH DOCUMENT LIBRARY AND SEND EMAIL ##
###############################################################################

 ########## Process "Expiring Documents" ###########
 $MailContent+= "<h2> Document Expiry Monitor - Report as on : $(Get-Date) </h2>"
 $ExpiringContentHeader =  "<h3 style='color: #333399;'> List of Expiring Documents: </h3> <table class='altrowstable' cellpadding='5px' cellspacing='5'><tr><th>Document Name </th><th>Created By</th><th>Created on</th><th> Expiry Date </th><th> URL </th></tr>"
 $MailContent += $ExpiringContentHeader 
 $ExpiringContent=""
 $ExpiredContent=""
 
# Loop through items and Get all Expiring Documents
 foreach ($ListURL in $LibraryURLs) 
 { 
  #Get the web 
  $web = Validate-Web $ListURL
  
  if($web -eq $null) {
   #Skip the current list and proceed with the next from array
   continue
  }
  
  #Get the List
  $list = Validate-List $ListURL
  if($list -eq $null) {
   #Skip the current list and proceed with the next from array
   continue
  }
  
 #Check if the list has the "Expiration Date" Column
 if ($list.Fields.GetFieldByInternalName($ExpiryDateColumnInternalName) -eq $false)
 {
  $Message = "$ListURL does not contains Expiration Date Field specified!"
  Write-Host $Message -ForegroundColor red
  Append-LogMessage $Message
  
  #Skip the current list and proceed with the next from array
  continue
 }

 # Write out the dates we're looking for
 $Message = "Searching $ListURL for Expiring documents with Expiration Date between " + $TodaysDate + " - " + $ExpirationDate
 Write-Host $Message -ForegroundColor DarkGreen
 Append-LogMessage $Message

 # Get all Expiring Documents
 $ExpiringQuery = '<Where><And><Geq><FieldRef Name="' + $ExpiryDateColumnInternalName + '" /><Value Type="DateTime" IncludeTimeValue="True">' + $TodaysDateFormatted + 

'</Value></Geq><Leq><FieldRef Name="' + $ExpiryDateColumnInternalName + '" /><Value Type="DateTime" IncludeTimeValue="True">' + $ExpirationDateFormatted + '</Value></Leq></And></Where>'
 $SPExpiringQuery = new-object Microsoft.SharePoint.SPQuery
    $SPExpiringQuery.ViewAttributes = "Scope='Recursive'"
 $SPExpiringQuery.Query = $ExpiringQuery
 $ExpiringListItems = $List.GetItems($SPExpiringQuery)
 $Message = "Found " + $ExpiringListItems.Count + " Expired document(s)."
 Write-Host $Message -ForegroundColor DarkGreen
 Append-LogMessage $Message

 #If There are some expiring documents found
  if($ExpiringListItems.Count -gt 0)
  {    
   foreach($Item in $ExpiringListItems)
   {
    $ExpiringContent+= "<tr> <td> $($item.Name)  </td> <td> $($item.File.Author.Name)  </td> <td> $($item.File.TimeCreated.ToString($DateFormat)) </td> <td> $($Item

[$ExpiryDateColumnInternalName].ToString($DateFormat)) </td>  <td> <a href='$($web.URL)/$($item.URL)'>$($web.URL)/$($item.URL)</a> </td> </tr>"
   }
  }
 }
 if($ExpiringContent.Length -eq 0)
 {
  $ExpiringContent+= "<tr> <td colspan=5> No Expiring Documents Found! </td> </tr>"
 }
 $ExpiringContent+= "</table><br/>" 
  
 $MailContent += $ExpiringContent
 
 ########## Process "Expired Documents " ###########
 $ExpiredContentHeader =  "<h3 style='color: #660033;'> List of Expired Documents: </h3> <table class='altrowstable' cellpadding='5px' cellspacing='5'><tr><th>Document Name </th><th>Created 

By</th><th>Created on</th><th> Expiry Date </th><th> URL </th></tr>"
  $MailContent += $ExpiredContentHeader 
 
 $ExpiredContent=""
# Loop through items and Get all Expired Documents
 foreach ($ListURL in $LibraryURLs) 
 { 
  if($web -eq $null) {
   #Skip the current list and proceed with the next from array
   continue
  }
  
  #Get the List
  $list = Validate-List $ListURL
  if($list -eq $null) {
   #Skip the current list and proceed with the next from array
   continue
  }
 
 #Check if the list has the "Expiration Date" Column
 if ($list.Fields.GetFieldByInternalName($ExpiryDateColumnInternalName) -eq $false) 
 {
  $Message = "$ListURL does not contains Expiration Date Field specified!"
  Write-Host $Message -ForegroundColor red
  Append-LogMessage $Message
  
  #Skip the current list and proceed with the next from array
  continue
 }

 # Write out the dates we're looking for
 $Message = "Searching $ListURL for Expired documents with Expiration Date between " + $TodaysDate + " - " + $ExpirationDate
 Write-Host $Message -ForegroundColor DarkGreen
 Append-LogMessage $Message

 # Get all Expired Documents
 $ExpiredQuery = '<Where><Lt><FieldRef Name="' + $ExpiryDateColumnInternalName + '" /><Value Type="DateTime" IncludeTimeValue="True">' + $TodaysDateFormatted + '</Value></Lt></Where>'
 $SPExpiredQuery = new-object Microsoft.SharePoint.SPQuery
    $SPExpiredQuery.ViewAttributes = "Scope='Recursive'"
 $SPExpiredQuery.Query = $ExpiredQuery
 $ExpiredListItems = $List.GetItems($SPExpiredQuery)
 
 $Message = "Found " + $ExpiredListItems.Count + " Expired document(s)."
 Write-Host $Message -ForegroundColor DarkGreen
 Append-LogMessage $Message 

 #If There are some expired documents found
  if($ExpiredListItems.Count -gt 0)
  {    
   foreach($Item in $ExpiredListItems)
   {
    $ExpiredContent+= "<tr> <td> $($item.Name) </td> <td> $($item.File.Author.Name) </td> <td> $($item.File.TimeCreated.ToString($DateFormat)) </td> <td> $($Item

[$ExpiryDateColumnInternalName].ToString($DateFormat)) </td>  <td> <a href='$($web.URL)/$($item.URL)'>$($web.URL)/$($item.URL)</a> </td> </tr>"
   }
  }
 }
 if($ExpiredContent.Length -eq 0)
 {
  $ExpiredContent+= "<tr> <td colspan=5> No Expired Documents Found! </td> </tr>"
 }
 $ExpiredContent+= "</table><br/>" 
 
 
 $MailContent += $ExpiredContent
 $MailContent += "</body></html>"

 #Email the Body 
 $EmailAddresses = Get-GroupEmails
 if($EmailAddresses -ne $null)
 {
  Send-Email $MailContent $EmailAddresses 
 }
 
 #Log to Tracking table
 LogTo-TrackingList $MailContent

###############################################################################
##  CLEAN UP ##
###############################################################################

# Log end of processing
$Message = "Finished Processing Document Expiration Monitor Script by $(Get-Date)."
Write-Host $Message -ForegroundColor DarkGreen
Append-LogMessage $Message

# Dispose of the web object
$web.Dispose()

Template.htm File content:
<html>
<head> 
<!-- CSS goes in the document HEAD or added to your external stylesheet -->
<style type="text/css">
body{
font-family: Calibri;
 height: 12pt;
}
table.altrowstable {
 border-collapse: collapse;
 font-family: verdana,arial,sans-serif;
 font-size:11px;
 color:#333333;
 border-width: 1px;
 border-color: #a9c6c9;
 border: b1a0c7 0.5pt solid;  
}
table.altrowstable th {
 border-width: 1px;
 padding: 5px;
 background-color:#8064a2;
 border: #b1a0c7 0.5pt solid;
 font-family: Calibri;
 height: 15pt;
 color: white;
 font-size: 11pt;
 font-weight: 700;
 text-decoration: none;
}
table.altrowstable td {
 border: #b1a0c7 0.5pt solid; font-family: Calibri; height: 15pt; color: black; font-size: 11pt; font-weight: 400; text-decoration: none;
}
</style>
</head>
<body>

PowerShell Script in Action:
Tracking List:



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


Wednesday, January 8, 2014

Fix "Sorry, this site hasn't been shared with you." Error in SharePoint 2013

Typically, if you don't have access to a SharePoint 2013 site and access requests are not enabled, You get : "Sorry, this site hasn't been shared with you" message when you try to access any SharePoint 2013 sites. Its a common issue and simply means that you have not been granted access to the site!
sorry this site hasn't been shared with you in sharepoint 2013

OK, How to solve this error?
Login to the site collection with either site collection administrator or Farm Admin (granted with "Full control" Web Application user policy!), grant appropriate access to the user in question by going to Site Settings >> People and Groups. Once you do this, users prompted for credentials instead of the Sorry, this site hasn't been shared with you error.

To confirm this issue is specific to a particular user's access rights, Try Login as a different user who has permission to the site already: http:/sharepoint-site-url/_layouts/closeConnection.aspx?loginasanotheruser=true

Still getting same "Sorry, this site hasn't been shared with you."?
  1. Might be because of cached credentials from a prior browser session. Try clearing IE cache: Open a new browser window >> Go to Internet options >> In the general tab, click the Delete button >> Make sure that passwords and temporary Internet files are selected. Try different browser such as Firefox!
  2. If you didn't run product and configuration wizard after installation/patch, you may get this error even if you are a site collection administrator. Run it once and get rid of this issue.
  3. Stop and Start "Microsoft SharePoint Foundation Web Application" service from Central Admin >>Application Management >>Manage services on server
  4. If are migrated from SharePoint 2010, or backup-restore/import-exported: If your source site collection is in classic windows authentication mode and target is in claims authentication, You must change classic mode authentication to claims-based authentication (Convert-SPWebApplication or $WebApp.MigrateUsers($true))
  5. If you have a custom master page verify its published! checked-out master pages could cause this issue. Try Check-in and make sure all resources such as CSS, Images, JS files are having atleast read access to all authenticated users.
  6. If you have this feature enabled: "Limited-access user permission lockdown mode" at site collection level - Deactivate it. - Because, this prevents limited access users from getting Form pages! 
  7. Try clearing the Distribution Cache, Do the IIS reset.
  8. On publishing sites: Make sure you set the cache accounts: Super User & Reader to a domain account for the SharePoint 2013 Web Application with appropriate rights - Configure SharePoint 2013 Object Cache Super User, Super Reader Accounts , http://technet.microsoft.com/en-us/library/ff758656.aspx


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


Monday, January 6, 2014

Start SharePoint Search Crawl using PowerShell

For some reasons, SharePoint search crawl scheduled didn't trigger. So I used this PowerShell script and Windows Task scheduler to trigger Incremental crawls.

Start SharePoint Search Full/Incremental Crawl using PowerShell:
Add-PSSnapin Microsoft.SharePoint.Powershell -ErrorAction SilentlyContinue

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

#Get the Local SharePoint sites content source
$ContentSource = $SSA | Get-SPEnterpriseSearchCrawlContentSource -Identity "Local SharePoint sites"

  #Check if Crawler is not already running
  if($ContentSource.CrawlState -eq "Idle")
        {
            Write-Host "Starting Incremental Crawl..."            
            $ContentSource.StartIncrementalCrawl()
            #$ContentSource.StartFullCrawl();
            #$ContentSource.PauseCrawl()
            #$ContentSource.StopCrawl()
       }
  else
  {
   Write-Host "Another Crawl is already running!"
   Write-Host "NAME: ", $ContentSource.Name, " - ", $ContentSource.CrawlStatus
  }   
We can also start / stop Search crawls in SharePoint 2013 or in SharePoint 2010 using this single line of PowerShell script:
Get-SPEnterpriseSearchCrawlContentSource -SearchApplication "Search Service Application" | where-object { ($_.Name -eq "Local SharePoint Sites") -and ($_.CrawlStatus -eq "idle") } | foreach { $_.StartIncrementalCrawl() }

Start Incremental Crawl in MOSS 2007 using PowerShell:

[void] [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
[void] [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.Office.Server")
[void] [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.Office.Server.Search")

$ServerContext = [Microsoft.Office.Server.ServerContext]::Default
$context =  [Microsoft.Office.Server.Search.Administration.SearchContext]::GetContext($ServerContext) 

$SSPContent = new-object Microsoft.Office.Server.Search.Administration.Content($context) 
$SSPContentSources =  $SSPContent.ContentSources 

foreach ($ContentSource in $SSPContentSources) 
{ 
  if ($ContentSource.Name -eq "Local Office SharePoint Server sites")
  {
    Write-Host "NAME: ", $ContentSource.Name, " - ", $ContentSource.CrawlStatus
    if ($ContentSource.CrawlStatus -eq [Microsoft.Office.Server.Search.Administration.CrawlStatus]::Idle)
    {
     Write-Host "Starting Incremental crawl"
       $ContentSource.StartIncrementalCrawl();
    }
    else
    {
       Write-Host "Another Crawl is already running!"
    }
  }
} 
This was helpful when user came with an requirement to run incremental crawl for each 15 min!

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


SharePoint 2013 Import Spreadsheet Errors and Solutions

Error: The list cannot be imported because a Microsoft SharePoint foundation-compatible spreadsheet application is not not installed or is not compatible with your browser.
The list cannot be imported because a Microsoft SharePoint foundation-compatible spreadsheet application is not not installed or is not compatible with your browser.

Solution: Use Internet Explorer 32 bit version!

How to Open Internet Explorer 32 bit version? Go to start >> Type "Internet Explorer" and pick the "Internet Explorer" link as in this screenshot.

Error: The specified file is not a valid spreadsheet or contains no data to import.
I'm sure the data is valid and in right format. I know the data is in right format, What's wrong?
SharePoint 2013 Import Spreadsheet Error: The specified file is not a valid spreadsheet or contains no data to import.  I'm sure the data is valid and in right format.

Solution: Well, SharePoint 2013 expects your SharePoint 2013 site to be in Trusted Sites List! So, Add your SharePoint site to Trusted Sites zone.

Here is How to Add SharePoint Site to Trusted Sites Zone:
Go to Internet Explorer >> Click on "Tools" Menu >> Internet Options >> Security >> Trusted Sites >> click on "Sites" button and Enter the URL of your SharePoint Site >> Click on "Add".
Add SharePoint Site to Trusted Sites Zone


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


Sunday, January 5, 2014

"This field can have no more than 255 characters." Error in Multiline Text Columns

Getting  "This field can have no more than 255 characters." error on SharePoint Multiple lines of text  columns?

Well, the fix is simple, we've the property  "Allow Unlimited length in document libraries" on Multiple lines of text fields. Once enabled, technically it can hold content up to 2 GB.
This field can have no more than 255 characters

We can also set this property programmatically either with C# or PowerShell:
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")

#Get-SPSite cmdlet for MOSS 2007
function global:Get-SPSite($url)
 {
    return new-Object Microsoft.SharePoint.SPSite($url)
 }

#Get-SPWeb cmdlet for MOSS 2007
Function global:Get-SPWeb($url)
{
  $site= New-Object Microsoft.SharePoint.SPSite($url)
        if($site -ne $null)
            {
               $web=$site.OpenWeb();
       
            }
    return $web
}
  
  #Parameters
  $web = Get-SPweb "http://sharepoint.crescent.com/regions/emea/se/"
  $ListName = "Employee of the Month"
  $FieldName = "Desciption"
 
  #Get the List 
  $list = $web.lists[$ListName]
 
  #Set the "Allow unlimited length in document libraries" option to true programmatically
  $list.Fields[$FieldName].UnlimitedLengthInDocumentLibrary= $true
 
  #Update the Field
  $list.Fields[$FieldName].update()

C# code:
    
    static void Main(string[] args)
        {
            SPSite mySite = new SPSite("http://sharepoint.crescent.com/regions/emea/se/");
            SPWeb myWeb = mySite.OpenWeb();

            SPList myList = myWeb.Lists["Employee of the Month"];
            SPField myField = myList.Fields["Description"];

            ((SPFieldMultiLineText)myField).UnlimitedLengthInDocumentLibrary = true;
            myField.Update();
        }

Unfortunately, in some of the OOTB list fields, "Allow Unlimited length in document libraries" property is not included in the field definition. E.g. "Description" field in SharePoint picture libraries! What's the workaround? Create a New multiline column and copy values from the existing OOTB column!

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


Wednesday, January 1, 2014

How to Get Managed Account Password in SharePoint?

SharePoint Managed accounts feature was introduced in its 2010 version, and of course its a wonderful feature to manage service accounts (I remember those old days.. We used to create a batch file to update password for each and everything in SharePoint 2007!). So, We utilized managed accounts in SharePoint 2013, enabled automatic password change. All went well until we needed the password for a particular managed account to install a third-party add-on! Luckily found this script to get managed account passwords in SharePoint.
Important: You must run this script as Farm Administrator! and make sure you are running the script as "Administrator"!!

Here is the PowerShell script to retrieve SharePoint managed account passwords:
Add-PSSnapin Microsoft.SharePoint.Powershell -ErrorAction SilentlyContinue

function Bindings()
{
 return [System.Reflection.BindingFlags]::CreateInstance -bor
 [System.Reflection.BindingFlags]::GetField -bor
 [System.Reflection.BindingFlags]::Instance -bor
 [System.Reflection.BindingFlags]::NonPublic
}
function GetFieldValue([object]$o, [string]$fieldName)
{
 $bindings = Bindings
 return $o.GetType().GetField($fieldName, $bindings).GetValue($o);
}
function ConvertTo-UnsecureString([System.Security.SecureString]$string)
{
 $intptr = [System.IntPtr]::Zero
 $unmanagedString = [System.Runtime.InteropServices.Marshal]::SecureStringToGlobalAllocUnicode($string)
 $unsecureString = [System.Runtime.InteropServices.Marshal]::PtrToStringUni($unmanagedString)
 [System.Runtime.InteropServices.Marshal]::ZeroFreeGlobalAllocUnicode($unmanagedString)
 return $unsecureString
}

Get-SPManagedAccount | select UserName, @{Name="Password"; Expression={ConvertTo-UnsecureString (GetFieldValue $_ "m_Password").SecureStringValue}}

This script decrypts and retrieves all SharePoint 2010 / SharePoint 2013 managed account passwords along with its user names.

Related post: How to Get IIS Application Pool Password?

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