Open Pdf file from SharePoint to Client Application and not on Browser



PDF files which are stored in a Sharepoint document library open browser automatically.
Even if you configure the advanced settings in the document library for browser-enabled documents to open in the client application, but it still opens the pdf in the web browser.

To solve this issue, you can use the below steps.

1- Go to your web browser.
2- Click on Add-ons.
3- Select "All Add-ons" from dropdown.
4- Select Adobe Reader add on and Disable it.
5- Refresh the browser.
6- Try to open the pdf file it will ask to open it in client applciation.

Checked-Out dates for documents

Nice script from internet to check the "Checked-Out date" for checked out documents

# enter your site URL
Add-PSSnapin microsoft.sharepoint.powershell
$spWeb = Get-SPWeb "Enter your website URL"

function GetCheckedItems($spWeb)
{
Write-Host "Scanning Site: $($spWeb.Url)"
foreach ($list in ($spWeb.Lists | ? {$_ -is [Microsoft.SharePoint.SPDocumentLibrary]})) {
    Write-Host "Scanning List: $($list.RootFolder.ServerRelativeUrl)"
    foreach ($item in $list.CheckedOutFiles) {
        if (!$item.Url.EndsWith(".aspx")) { continue }
        $writeTable = @{
        "URL"=$spWeb.Site.MakeFullUrl("$($spWeb.ServerRelativeUrl.TrimEnd('/'))/$($item.Url)");
        "Checked Out By"=$item.CheckedOutBy;
    "Author"=$item.File.CheckedOutByUser.Name;
        "Checked Out Since"=$item.CheckedOutDate.ToString();
    "File Size (KB)"=$item.File.Length/1000;
    "Email"=$item.File.CheckedOutByUser.Email;
        }
        New-Object PSObject -Property $writeTable
    }
    foreach ($item in $list.Items) {
        if ($item.File.CheckOutStatus -ne "None") {
            if (($list.CheckedOutFiles | where {$_.ListItemId -eq $item.ID}) -ne $null) { continue }
            $writeTable = @{
            "URL"=$spWeb.Site.MakeFullUrl("$($spWeb.ServerRelativeUrl.TrimEnd('/'))/$($item.Url)");
            "Checked Out By"=$item.File.CheckedOutByUser.LoginName;
        "Author"=$item.File.CheckedOutByUser.Name;
            "Checked Out Since"=$item.File.CheckedOutDate.ToString();
        "File Size (KB)"=$item.File.Length/1000;
        "Email"=$item.File.CheckedOutByUser.Email;
            }
            New-Object PSObject -Property $writeTable
        }
    }
}
foreach($subWeb in $spWeb.Webs)
{
GetCheckedItems($subWeb)
}
$spWeb.Dispose()
}

GetCheckedItems($spWeb) | Out-GridView

# alternative output file
# GetCheckedItems($spWeb) | Out-File c:\CheckedOutItems.txt -width 300

Windows PowerShell script for reading the SharePoint Secure Store

when you assign a credential in a secure store for any target application. there is no way to check which credentials you used last time.
 
Below powershell script can be used to read the credentials inside the secure store.



Powershell to update quick launch in SharePoint 2013

Below is the powershell, which is being used to

1- update the title and URL of existing heading in left navigation.
2- add all the sibling subsites (title and URL) as a node under the heading.

#SharePoint site url
$MainSiteURL = "Site URL for which you want to change the quick launch"
$ParentSiteURL = "Site URL of the parrent site of above site as you want to add the sibling subsites"
$ParentSiteName = "Name of a parent site"

           
#Get the SPWeb object for the site url           
$MainWeb = get-spweb $MainSiteURL
$ParentWeb = get-spweb $ParentSiteURL

#Get the quick launch menu           
$ql = $MainWeb.Navigation.QuickLaunch;           

#change the heading title and URL
$qlHeading = $ql | where { $_.Title -eq "subsites" }
$qlHeading.Title = $ParentSiteName
$qlHeading.Url = $ParentSiteURL
$qlHeading.Update()

# get all subsites
if($ParentWeb.Webs -ne $null)
{
    foreach($sitesUnderParentWeb in $ParentWeb.Webs)
    {
        # to create a new node
        $newnode = New-Object Microsoft.SharePoint.Navigation.SPNavigationNode($sitesUnderParentWeb.Title, $sitesUnderParentWeb.Url, $true)
        # add this node to heading
        $qlHeading.Children.AddAsLast($newnode)
       
    }
}
$MainWeb.Update()           

SharePoint Online Backup and Restore - Nice article

I got the below nice article about SharePoint Online backup and Restore by Threewill

http://www.threewill.com/the-4-options-you-need-to-know-about-sharepoint-online-backup-and-restore/ 


  1. Use the recycle bin and version history.
  2. Use a 3rd party tool for backup and restore (there are several).
  3. Manually backup sites, lists, and libraries 
  4. Create an Office 365 support request 
Few more pieces of information:
  • Site collection backups are performed every 12 hours and are kept for 14 days.
  • If you want to restore a backup, you need to create a support ticket and specify the earliest backup time, latest backup time, and optimal backup time.  Say your site collection was messed up during the day on Tuesday.  You could state the earliest backup time as close of business Monday (e.g., 6 PM), the latest backup time as open of business on Tuesday (e.g., 6 AM), and the optimal backup time as Tuesday at 4 AM.  The support team will get you the best backup based on this information.  You should have at least 12 hours between the earliest and latest times.
  • The restoration is done to a site collection.  The entire site collection will be replaced and any changes made after the backup time will be lost (must be re-done after the restore).
  • Once a restore is requested, it may take 2 or more days for the restore to be performed.  This is done based on O365 support’s triage process and the perceived priority of the request.  The tenant license or overall number of users for the tenant does not change the priority.

Check if your DNS is working properly - Online solution

Below is the URL to verify if the DNS is working correctly.

http://dnscheck.pingdom.com/

Provision Service using Powershell


Below is the command to provision or un-provision any service


Add-PSSnapin microsoft.sharepoint.powershell
Get-SPServiceInstance | Where-Object {$_.Server.Name -eq "NameofServer"} | Sort-Object TypeName | Format-Table -AutoSize
$si = Get-SPServiceInstance | Where-Object {($_.TypeName -match "NameOfServiceApplication") -and ($_.Server.Name -eq "NameOfServer")}
$si | fl
$si.Unprovision()
$si.Provision()
$si.Status
While ($si.Status -eq "Provisioning")
{
    Start-Sleep 3
    Write-Host "." -NoNewline
    $si = Get-SPServiceInstance | Where-Object {($_.TypeName -match "NameOfServiceApplication") -and ($_.Server.Name -eq "NameOfServer")}
}

Create Site collection using Powershell - Including Default groups

The below command is used to create a hosted Site collection under any web application using power-shell.



Add-PSSnapin "Microsoft.sharepoint.powershell"

$url = "Name of your Hosted Site collection"
$hostHeaderWA = "Name of your web application"
$SCollectionTitle = "Title of your site collection"
$SCollDescription = "Description of your site collection"

New-SPSite $url -HostHeaderWebApplication $hostHeaderWA `
                -Name $SCollectionTitle `
                -Description $SCollDescription `
                -OwnerAlias 'DomainName\AccountName' `
                -language 1033 `
                -Template 'STS#0'

The when you create your site collection (OR hosted site collection), you will see the default Owners/Members/Visitors groups are missing.
To create those groups, use the below Power-Shell command

$web = Get-SPWeb $url
$PrimaryLogin = $web.EnsureUser("DomainName\AccountName")
$web.CreateDefaultAssociatedGroups($PrimaryLogin,"","")

you can run the entire Power-Shell command together as well.



SQL Standard OR Enterprise Version of RS (Reporting services) for SharePoint 2013

I got a nice finding about using either a MSSQL Standard OR Enterprise version of RS for SharePoint 2013.

1- if you use the SQL Standard 2012 for RS in SharePoint 2013, you will not be able to activate the SQL Server Reporting Services on more than one application Servers of SharePoint.

2- If you use Enterprise version of SQL 2012, the SQL Server Reporting Service can be started on multiple application servers.

Here is more details about it.

http://netwovenblogs.com/2013/08/04/reporting-services-in-sharepoint-2013-integrated-mode-cannot-support-scale-out-mode/

SQL Server Reporting Services Scale-out mode is supported by following SQL Server editions: Enterprise, Business Intelligence. (Refer MSDN: Features Supported by the Editions of SQL Server 2012)
With your SQL Server 2012 Enterprise or Business Intelligence editions, under your SharePoint 2013 (2010) you could always scale out to more than one SharePoint server. (Refer MSDN Add an Additional Report Server to a Farm (SSRS Scale-out) )
While you have SQL Server 2012 Standard edition, under the SharePoint 2013 Farm, you can have only one instance of SQL Server Reporting Services in the SharePoint Integrated mode. While you try to start another instance of Reporting Service in the farm on different server within the Farm, you will receive the above message.
If you intend to start the SQL Server Reporting Services on a different server than the service is currently running, you should first stop the service on the current running service and then start on your desired server. But also be aware other installation and configuration requirements for hosting the SSRS Service on the Server before you try to start the SSRS Service on a new server

Configure Custom Access Denied Page - SP 2013

I found a really nice article for creating custom access denied page from Danish.

http://a2zdinesh.blogspot.in/2014/05/configure-custom-access-denied-page-bug.html


Danish also explained the step by step configuration (Development and deployment) for creating custom access denied page.

Running Powershell for SharePoint Online from local machine

1- download SharePoint Online Management Shell  on your local machine.

Download SharePoint Online Management Shell

2- once this is installed, you will find an icon for Powershell Online.

3- click on that icon.

4- before you execute any command for SharePoint online. run the below command

Import-Module Microsoft.Online.SharePoint.PowerShell -DisableNameChecking

5- With SharePoint 2013 online you need to connect to your tenant administration site to be able to do anything.

Connect-SPOService –url  $siteCollectionUrl –Credential $O365Credential

6-Note: I was facing an error while executing the above command. i took the help from microsoft office 356 community. see the link below.

Help from office 365 community


7- Finally i got it run. after executing the step 4. i ran the below command.
$cred = [System.Net.CredentialCache]::DefaultCredentials
[System.Net.WebRequest]::DefaultWebProxy.Credentials = $cred

8- then i ran the command in step 5 and i was able to connect to SharePoint Online powershell.




PowerShell script to Take a backup of Service application in SP 2013

 
Below is the Power Shell script to Take a backup of Service application in SP 2013

 
$currentDateTime = (Get-Date -Format yyyy-MM-dd-HH-mm)
$SrvAppFolder = Test-Path "\\$env:computername\SPServiceApplicationBackup\"


#add sharepoint snapin
Add-PSSnapin microsoft.sharepoint.powershell 
    
#Backup Service Applications
#Excel Services Application
Backup-SPFarm -Directory $backupSAFolder -BackupMethod Full -Item "Farm\Shared Services\Shared Services Applications\Excel Services Application"
        
#Secure Store Service 

Backup-SPFarm -Directory $backupSAFolder -BackupMethod Full -Item "Farm\Shared Services\Shared Services Applications\Secure Store Service"
Backup-SPFarm -Directory $backupSAFolder -BackupMethod Full -Item "Farm\Shared Services\Shared Services Proxies\Secure Store Service"

Re-ghost Items presented in Master page gallery

I found a nice article about re-ghost items (specially for master pages and page layouts)

http://mosshowto.blogspot.nl/2008/10/re-ghost-master-pages-sharepoint.html

Error While Creating Web Application in SharePoint 2013

Error : While creating a new web application in SharePoint 2013 using central administration, I was getting the below error every time. "Internet Explorer cannot display the webpage".















Solution :
1- Go to IIS Manager.
2- Look for the application pool "DefaultAppPool"
3- Change the following 3 Process Model time settings
3a.Ping Maximum Response Time --> set to 400
3b.Shutdown Time Limit --> set to 400
3c.Startup Time Limit --> set to 400
4. reset the IIS. Try to create the web application once again.



Once the web application is created, you can revert the settings to 90 and finally do the IISRest Once again. I got the above information from the below post.
http://blogs.ibs.com/Duane.Odum/Lists/Posts/Post.aspx?ID=33

Find List details if you know the List IDs

if you only know the list id and want to know the other details of the list, below is the code to get that
protected void Page_Load(object sender, EventArgs e)
{
string[] _listArray = {"List ID 1", "List ID 2", "List ID 3"};
using (SPSite oSite = new SPSite("MySiteURL"))
{
SPWeb oWeb = oSite.OpenWeb();
SPListCollection allLists = oWeb.Lists;
foreach (SPList list in allLists)
{
foreach (string singleArraylist in _listArray)
{
if (list.ID.ToString().ToUpper() == singleArraylist.ToString().ToUpper())
{
Response.Write("List Name :\t" + list.Title + " List ID :" + list.ID + "");
}
}
}
}
}

Know the site template used for the SharePoint site

Using STSADM.EXE: It needs high level permissions. Means the user should be an administrator on the server. Below is the command we need to use for knowing the site template. stsadm.exe -o enumallwebs -database [content database name] for more details see the below link http://praveenbattula.blogspot.nl/2010/08/know-site-template-used-for-sharepoint.html

SharePoint 2003 to MOSS 2007 Upgrade: Database migration

I found a really nice article about database migration from SharePoint 2003 to MOSS 2007.

the blog post describe, how to take a backup of SP 2003 content database and migrate the same in MOSS 2007 with step by step instruction

http://farhanfaiz.wordpress.com/2008/05/23/sharepoint-upgrade-database-migration/

Decompile .net assembly ildasm

if you want to de compile a .net assembly (dll), you can use a visual studio option to de-complie it.

if you have visual studio installed in the machine. 

1- Go to Visual Studio Tools --> Visual Studio command prompt.
2- write ILDASM

it will open an interface where you can open your dotnet assembly and de-compile it. the best option to decompile any .net dll is .Net Reflector by red-gate. Please visit the below link to download the .Net reflector. It allows you to export the entire source code with in the assembly.

http://www.red-gate.com/products/dotnet-development/reflector/

Error : The attach operation cannot continue because another object in this farm already contains the same ID

In SharePoint 2013. I tried to remove the content DB from the web application by using the remove database option.
after this, I tried to add the content database to the same web application again, but I was continuously getting the error : "The attach operation cannot continue because another object in this farm already contains the same ID"

I found some powershell, through which you can get rid of this problem. it is for sure that the content DB is attached to the web application but some how it is not visible and that's why I was not able the content DB to the web application.

To check if the Database is already connected to the web application, use the below PS command.

Get-SPDatabase | where{$_.Name -eq “Name of your WEB Application“}

This PS will give you the result, if the content DB is already attached.the details provided by this command 
ID
Name
Web Application
Server
Current Site count.

Now you can take the ID of this content DB and use the below command to remove this DB from Web application.
Note: You can also use name but sometime name doesn't work properly.


Dismount-SPContentDatabase 12345678-90ab-cdef-1234-567890abcdef
http://technet.microsoft.com/en-us/library/ff607764.aspx
 
This way it will dismout the content DB and now you can add the 
content DB to the web application from central admin or use the below
command to mount it
Mount-SPContentDatabase “MyDatabase” -DatabaseServer "MyServer" -WebApplication http://sitename
http://technet.microsoft.com/en-us/library/ff607581.aspx


Get Started with Powershell for SharePoint

Below is the nice link to get start with SharePoint powershell..

simple-talk Link