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