Thursday, May 19, 2016

The content Type with Id was Found in the Current Site Collection or in a SubSite

I have installed the reporting services in the SharePoint 2013 environment. I have created a team site in which I was trying to activate the "Report Server Integration Feature",  and was getting  following error

Message: The content type with Id 0x010100C3676CDFA2F24E1D949A8BF2B06F6B8B defined in feature {e8389ec7-70fd-4179-a1c4-6fcb4342d7a0} was found in the current site collection or in a subsite.


Run the following Powershell script to activate the "Report Server Integration Feature"
 
 Enable-SPFeature -Identity E8389EC7-70FD-4179-A1C4-6FCB4342D7A0 -Url http://siteurl  -force

Wednesday, July 1, 2015

SharePoint 2013 site locked in read only mode

If you were trying to run a back up or stop the backup but your site is showing currently in read only mode and option to unlock at central admin is also disabled, below is the powershell commnds you can run to make the site active again.

PS C:\Users\root> $Admin =  new-object Microsoft.SharePoint.Administration.SPSiteAdministration('http://YourSite')

PS C:\Users\root> $Admin.ClearMaintenanceMode()

One ran, refresh the site and you will see the site in full active mode.

Tuesday, June 23, 2015

Clear SharePoint Config cache data on the servers

Sometimes we need to clear the config cache data on the SharePoint servers which supposed to be fixed or we are trying to fix fetching old configured data from the servers. Like we do dns flush, same way we need to clear the config cached data for SharePoint.
Below are the steps to clear the cache:-

1) STOP the timer service manually
2) Run the following powershell script below to clear the config cached data
--------------------------------------------------------------------------------------------------------------------------
Write-Host "This script clears your SharePoint config cache on this server. This should be done on all servers simultaneously.";
$confirm = Read-Host "Have you stopped the timer service on all SharePoint servers? y or n"
If ($confirm -eq "y" -or $confirm -eq "yes" ) {
                Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
                               
                #Retrieve the ID of the configuration database from the registry. This ID identifies the caching folder on disc.
                $ConfigDb = (Get-SPDatabase | Where {$_.TypeName -eq "Configuration Database"}).ID
                $ConfigDbId = $ConfigDb.GUID

                # Creating the folder path
                $CacheFolder = Join-Path -Path ([Environment]::GetFolderPath("CommonApplicationData")) -ChildPath "Microsoft\SharePoint\Config\$($ConfigDbId)"

                # Clearing out the cache
                Write-Host "$env:COMPUTERNAME - Clearing cache folder"
                Get-ChildItem "$CacheFolder\*" -Filter *.xml | Remove-Item
                Get-ChildItem "$CacheFolder\*" -Filter *.tmp | Remove-Item

                # Locate the cache ini file and reset it by writing the value '1' into the file.
                Write-Host "$env:COMPUTERNAME - Resetting cache ini file"
                $CacheIni = Get-Item "$CacheFolder\Cache.ini"
                Set-Content -Path $CacheIni -Value "1"

                Write-Host "Please confirm Cache.ini is reset to '1' and XML/TMP files have been removed. The explorer window should open shortly (~25 seconds)."
                Start-Sleep -Seconds 25
                $ShellExp = new-object -comObject Shell.Application
                $ShellExp.open($CacheFolder);

                Write-Host "Config cache has been cleared. Please start the timer service and confirm that the XML files are re-populating."
}
Else {
                Write-Host "Script has been canceled."
}
-----------------------------------------------------------------------------------------------------------------------
3) Restart the Timer service once above script is executed successfully.

The script will also open up the explorer window with cache files location and will see repopulating the directory with new files

Powershell to get all users in Owners group of site collection and sub-sites

If you want to get the users name, information for all the owners in a site collection and export it to an excel sheet, follow the below powershell script to do that:-
-------------------------------------------------------------------------------------------------------
Add-PsSnapin Microsoft.SharePoint.PowerShell


Start-SPAssignment -Global


Get-SPSite http://yoursite/
Get-SPWeb -Limit All |
  where { $_.HasUniquePerm -and $_.AssociatedOwnerGroup -ne $null } |
  foreach { $TTNweburl = $_.Url; $_ } |
  Select -ExpandProperty AssociatedOwnerGroup |
  Select -ExpandProperty Users |
  Select {$TTNweburl}, UserLogin, DisplayName | Export-Csv -Path d:\output.csv -Encoding         ascii -NoTypeInformation

Stop-SPAssignment -Global
----------------------------------------------------------------------------------------------------------------
above script will list all the users and save the output in a csv file in provided location.
Text in bold above needs to be changed with your environment changes.

Tuesday, May 12, 2015

Upgrade is currently disabled for your site collection

You get the message that upgrade is currently disabled when you try to do site collection upgrade option under Site Collection administration or you try with Powershell.

Use the below command in powershell to enable the site for upgrading.

$site=Get-SPSite "http://SPSITE"
$site.AllowSelfServiceUpgrade=$true

How to deploy WSP Solution in compatibility mode using powershell

As there is no option in Central Administration to deploy a solution in Compatibilty mode, we can use powershell to deploy a solution.

The Suggested method for this type of deployment is:-

Install-SPSolution –Identity Solution.wsp –GACDeployment –CompatibilityLevel {14,15}

Wednesday, April 29, 2015

How to change account for Distributed Cache Service in SP 2013?

One need to have managed account to run the distributed cache serverice under that. Below is the powershell command to change or run the service:-


$farm = Get-SPFarm
$cacheService = $farm.Services | where {$_.Name -eq "AppFabricCachingService"}
$accnt = Get-SPManagedAccount -Identity domain_name\user_name
$cacheService.ProcessIdentity.CurrentIdentityType = "SpecificUser"
$cacheService.ProcessIdentity.ManagedAccount = $accnt
$cacheService.ProcessIdentity.Update() 
$cacheService.ProcessIdentity.Deploy()


You can also Start the service as below:-

Add-SPDistributedCacheServiceInstance

and to remove a Cache host:-


Remove-SPDistributedCacheServiceInstance

Friday, March 27, 2015

Sign in as different user in SharePoint 2013

Sign in as different user has been removed from the SharePoint 2013 could be because of the users switching between accounts and making customizations to the existing page directly.


below is the way we can make it appear on the SharePoint sites:-


  • Locate the file \15\TEMPLATE\CONTROLTEMPLATES\Welcome.ascx and open in a text editor.
  •  Add the following element below the existing element "ID_PersonalInformation"


    <SharePoint:MenuItemTemplate runat="server" ID="ID_LoginAsDifferentUser"
     Text="<%$Resources:wss,personalactions_loginasdifferentuser%>"
     Description="<%$Resources:wss,personalactions_loginasdifferentuserdescription%>"
     MenuGroupId="100"
     Sequence="100"
     UseShortId="true"
     />


    And Now save the file. Do it on all the SP servers. Refresh the site now and you should be able to see it.

    Thursday, March 5, 2015

    How to schedule automatic backup of a site collection?

    To Schedule automatic backup of the site, you need to have your powershell script ready which we will schedule as below. You can have the script from here:-
    http://sharepointfamily.blogspot.com/2015/03/how-to-backup-site-collection-in.html

    1) Copy your ps1 file in some directory where you want to take backup every night.
    2) Go to Windows Task Scheduler and create a new JOB in it.ex- SiteBackup
    3) Under Task properties, you can set job to run for a given time under Triggers.
    4) Under Actions, select Start a Program and under programs\cripts, we need to put path to powershell. Foe ex:- C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe. And under "Add arguments" put " -WindowStyle Hidden & 'c:\Backup\Backupsite.ps1' " () Path to the saved PS1 (powershell script for doing site backup).

    5) Then you need to give a username and password to run this task in thw windows scduler based on your time.
      Once done, Click OK and you are good to go. Site will be created everyday with datetime stamp.

    How to backup a site collection in Sharepoint using Powershell?


    Add-PsSnapin Microsoft.SharePoint.PowerShell
    Start-SPAssignment -Global            # This cmdlet takes care of the disposable objects to prevent memory leak.

    $today=Get-Date -format "MM-dd-yyyy HH.mm.ss" # Get current date and format it to avoid invalid characters such as "/" and ":"

    $mySite="http://site"     # Replace with your site collection URL

    $backupLocation="c:\backup\$today"        # Replace with your backup location

    $logFile="$backupLocation\BackupLog.log"    # Replace with your desired log file location
     #check if backup directory exist. if not create them.
        if (-not (Test-Path $backuplocation)) {
            New-Item $backuplocation -type directory
        }
    write-Host Start backing up $mySite to $backupLocation
    try
    {
        # Create a new backup file and name it based on current date. If you want to create only 1 backup file and overwrite it each time the backup is run, you can replace "$today.bak" with your desired file name.
        Backup-SPSite -Identity $mySite -Path $backupLocation\$today.bak -force -ea Stop
        write-Host Backup succeeded.
      # Write success message to the log file
        write "$today    $mySite successfully backed up.">>$logFile   
    }
    catch        # If the process failed
    {
        write-Host Backup failed. See $logFile for more information.
        # Write error message to the log file
        write "$today    Error: $_">>$logFile

    }   
    Stop-SPAssignment -Global
    Remove-PsSnapin Microsoft.SharePoint.PowerShell
    write-Host "Finished script."

      
        

    Wednesday, March 4, 2015

    How to enable cell storage service in a Sharepoint environment for Office 2007 documents to open in Read/Write mode?

    Run the below script to enable back the cell storage service at SP web application level for Office 2007 documents to open in read\write mode.

    #-----------------------------------------------------
    # Enable cell storage
    # This script will enable cell storage on a given
    # SharePoint web application
    #-----------------------------------------------------

    # Set this to the URL of your web application

    $webApplicationURL = "http://contoso.com"


    #-----------------------------------------------------
    # Script body - nothing to change here
    #-----------------------------------------------------
    if((get-pssnapin 'microsoft.sharepoint.powershell' -ea 0) -eq $null){add-pssnapin microsoft.sharepoint.powershell}
    $wa = get-spWebApplication $webApplicationURL -ea 0
    cls

    if($wa -ne $null)
    {
        if($wa.cellStorageWebServiceEnabled)
        {
            write-host "Cell storage is already enabled on the web application $($wa.url)."
        }
        else
        {
            $wa.cellStorageWebServiceEnabled = $true
            $wa.update()
            write-host "Cell storage was successfully enabled on the web application $($wa.url)"
        }
    }  
    else
    {
        write-host "Couldn't find web application $webApplicationURL."
    }

    Office 2010 Documents in SharePoint 2010 opening in Read-Only but Office 2007 opening fine in Read/Write

    There are some issues when you move to Office 2010 from office 2007 in SharePoint and documents start opening in Read only mode and are not editable.
    Please use the below script to run to disable-cellstorage script service for office at SP Web application level.

    #-----------------------------------------------------
    # Disable cell storage
    # This script will disable cell storage on a given
    # SharePoint web application
    #-----------------------------------------------------

    # Set this to the URL of your web application

    $webApplicationURL = "http://webapp"


    #-----------------------------------------------------
    # Script body - nothing to change here
    #-----------------------------------------------------
    if((get-pssnapin 'microsoft.sharepoint.powershell' -ea 0) -eq $null){add-pssnapin microsoft.sharepoint.powershell}
    $wa = get-spWebApplication $webApplicationURL -ea 0
    cls

    if($wa -ne $null)
    {
        if($wa.cellStorageWebServiceEnabled)
        {
            $wa.cellStorageWebServiceEnabled = $false
            $wa.update()
            write-host "Cell storage successfully disabled on the web application $($wa.url)."
        }
        else
        {
            write-host "Cell storage is not currently enabled on the web application $($wa.url)"
        }
    }  
    else
    {
        write-host "Couldn't find web application $($wa.url)"
    }


    Below is the link to learn more about cellstorage service.
    http://blogs.architectingconnectedsystems.com/blogs/cjg/archive/2013/01/10/CellStorage.svc-_2D00_-Intelligence-Updating-with-Office-Clients.aspx

    Saturday, December 20, 2014

    An error has occurred during report processing. (rsProcessingAborted) Cannot impersonate user for data source 'DataSource1'. (rsErrorImpersonatingUser) This data source is configured to use Windows integrated security. Windows integrated security is either disabled for this report server or your report server is using Trusted Account mode. (rsWindowsIntegratedSecurityDisabled)

    We were getting above error when trying to open the reports in Sharepoint where everythign seemed to be configured correctly
    SP 2010 integration with Report server in Sharepoint Mode, Authentication was correct, reports were correct as was working fine in other environment and Sql server report server was showing integrated secuirty enabled.

    Here is the solution that worked in our case.
    1) This is related to permission issue.
    Open IIS manager, click on the site, click authentication and make sure you have the Windows and ASP.Net impersonation enabled on the site.Try to enabled Anonymous access for few mins and then do the iisreset. Once you do that and after few min, you will see that reports started opening without any errors. Once you conform its working, stop the Anonymous and restart the IIS again.
     Once you do that, you will see site reports opening without any issue.

    Sometime it is related to access to a folder or some settings that needs to be enabled but hard to find where is that the reports are looking for. Hope it helps people struglling with this isse as i was .:)

    The request failed with HTTP status 401: Unauthorized in Sharepoint logs

    Below is one of the solution suggested by microsoft in this types of issue
    1) Disable Loopback check on SSRS server (Method 2)
    1. Click Start, click Run, type regedit, and then click OK.
    2. In Registry Editor, locate and then click the following registry key:

      HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa
    3. Right-click Lsa, point to New, and then click DWORD Value.
    4. Type DisableLoopbackCheck, and then press ENTER.
    5. Right-click DisableLoopbackCheck, and then click Modify.
    6. In the Value data box, type 1, and then click OK.
    7. Quit Registry Editor, and then restart your computer.
     
    2) The next thing you want to try to check the authentication level on your IIS. This is related to permission issue. We had the simlar problem in SSRS reporting not opening a custom reporting page containing report viewer webpart in a https site
     Open IIS manager, click on the site, click authentication and make sure you have the Windows and ASP.Net impersonation enabled on the site. Check the same for the Default site if you are using it.

    How to enable Incoming email on the list/Library in Sharepoint

    Below are the steps that we need to perform to enable a library to receive incoming emails.

    1) SMTP service has to be installed and enabled on the SP WFE server. This can be added from Windows Server manager under Features and add the SMTP feahttps://www.blogger.com/blogger.g?blogID=122518409722023608#editor/target=post;postID=695350418594854018ture
    2) Next step is to open the IIS 6.0 amangement console and make sure that SMTP virtual server is up and running. If you want to ahve your own name, stop the existing one and create a new one with a good name and run it.
    3) Now you open the windows serverices and start the SMTP service in WFE server and make sure it is set on Automatic.
    4) By default the port assigned to SMTP service is 25. so make sure you have port open and is not blocked to enable the incoming email service.
    5) Now open Central admin, configure Incoming email settings,
    Select Yes to “Enable site on this server to receive e-mail”
    Select “Automatic” for Setting mode or Advanced (Put the system drive inetpub directory for drop folder)
    Select “Yes” to use the SharePoint Directory Management Service to create distributions groups and contacts.
    Enter your Active Directory container details, i.e. the Organizational Unit container that we created specifically for our SharePoint 2010 contacts.
    Ensure that your SMTP server details are correct, this should be the fully qualified domain name of your SMTP service that was installed on your SharePoint Server.
    6) Make sure following accounts are added on drop folder with below permissions
    WSS_Admin_WPG – Full Control and
    WSS_WPG – Read & Execute / List folder Contents / Read
    7) Also make sure that application pool account has read permission on the Drop folder as well to carry email over to the site level.
    8)  Now open the list\library and
    Click on Incoming e-mail settings.
    Select “Yes” to allow this document library to receive e-mail.

    Thats it. now try sending email to the address and you will see email in the library

    Below is a very good link with screenshots that can help
    http://sharepointgeorge.com/2010/configuring-incoming-email-sharepoint-2010/

    Powershell throwing error the execution of scripts is disabled on this system.

    This is the message we get it when try to run any powershell script on the SP server where execution olicy is disabled. It is based on tht 64 and 32 bit tyoe. We have to ensure that the execution policy is enabled on both types of it.
    Run the following command:-
    :- Set-ExecutionPolicy RemoteSigned
    Once ran, you can verify using following command
    :- get-executionpolicy
     

    Tuesday, November 25, 2014

    The installation of this package failed when you run SP Cumulative Update

    When you try to run the CU.exe file to upgrade your SP farm, you get the below message
    The installation of this package failed

    Solution:- The way it works is that you need to have the ca file also installed in the same folder where you have the EXE file. It looks for some content through that cab file and hence needed during the upgrade process.

    Another way around is that you can run from a network directory. 

    microsoft.sharepoint.administration.spserver needs upgrade when you upgrade your SP farm

    You get this message when you are trying to upgrade your SP farm by running the following command
    stsadm.exe -o localupgradestatus

    It displays the mess saying that upgrade required. Because there are still some features which did not get install, run the following command under bin directory

    PSConfig.exe -cmd upgrade -inplace b2b -force -cmd applicationcontent -install -cmd installfeatures

    Once done, refresh the page and upgrade status message should disappear. 

    Monday, November 17, 2014

    How to extract files out of SharePoint service Packs and CU?

    All,
     when we are doing scripted SP installation, we are looking to have all files at one place so that we can update the SP with all updates in once. But .exe files doesnt get carry from the scripts.
     Below is the command we run to extract the files and put in our CU updates folder.

    1) Open cmd
    2) "D:\Software\Office 2007\microsoft_office_suite_service_pack_2_x64.exe" /extract:"d:\updates\CUExtractFiles"

    Thursday, November 13, 2014

    How to configure Search from scratch in SharePoint 2010 farm?

    This is for every SP person who is configuring search i the environment.
    Here is a very excellent article on dng that and explainng all the components of the search.

    http://sharepointgeorge.com/2010/configuring-enterprise-search-sharepoint-2010/