Sunday, July 31, 2011

Find and Delete Orphaned Site Collections, Items in SharePoint

Orphaned Site Collection in SharePoint
Orphaned sites are broken sites created in situations like Restore interrupt/failure. During a migration project, I had to clean the SharePoint sites before migration as the preupgradecheck reported a huge list of orphaned sites.
remove Orphaned site collections in SharePoint

How to Delete Orphaned SharePoint Sites:
There are many ways to remove orphaned site collections in SharePoint. To remove orphaned site collections in SharePoint 2007 or in SharePoint 2010, use one of the following method:

 1.  Detach the content DB and attach again

 2.  To detect orphaned items, use the following command line:
stsadm -o databaserepair -url http://Web-App-URL -databasename <database Name>

To delete orphaned items, use the following command line:
stsadm -o databaserepair -url http://Web-App-URL -databasename <database Name> -deletecorruption
 KB: http://support.microsoft.com/kb/918744

3. Do STSADM –o EnumAllWebs, note down the Orphan site id's, and then execute
 
    stsadm -o deletesite -force
   -siteid <site ID> (ID is listed in an output from enumallwebs)
   -databasename <database name>
   -databaseserver <database server name>

This will delete orphaned site collection in SharePoint.

PowerShell script to find and delete orphaned items in SharePoint:
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

$ContentDBColl = Get-SPContentDatabase

ForEach ($Database in $ContentDBColl)
{
   Write-Host "Detecting Orphans for " $Database.Name
   $Database.Repair($true)
}
Fix Orphaned Items in SharePoint 2013:
SharePoint 2013 comes with a health analyzer rule to detect and fix orphaned items. Head-on to SharePoint 2013 central administration >> Monitoring >> Click on "Review problems and solutions" under Health Analyzer >> pick "Content databases contain orphaned items." from the list.

Click on "Repair Automatically" to delete orphaned items.

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


Sunday, July 24, 2011

Host Named Site Collections in SharePoint


What is Host Named Site collections?
Host-named site collections are the best option if you want to create multiple root-level site collections within a web application. (Or Unique URL for each site collection)

SharePoint supports both path-based & host-named site collections. The primary difference is: All path-based site collections in a Web application share the same host name (DNS name), where as each host-named site collection in a Web application is assigned with a unique DNS name.

In other words:
  • Host-named site collections allow you to create many root-level host-named sites within a single Web application. 
  • With path-based sites, you are limited to a single root-level site collection within a Web application
Host Named Site collections in SharePoint

What are the advantage/disadvantages of Path Based vs Host Named Site Collections:
Path-Named:The major advantage of path-based sites is that these sites can be accessed from any zone that you configure. Also, the alternate access mappings feature, which provides support for SSL, works with all path-based sites. you are limited to a single root-level site collection within a Web application, But the managed paths option allows you to create top-level sites beneath the initial root-level site collection.

Host-Named:They give you more control over URLs. host-named site collections are only available through the default zone.The alternate access mappings feature does not work. You can't use both HTTP and HTTPS together. You can create up to 100,000 host-named site collections within a single IIS Web site. Another great advantage of HNSC is: You can use single wildcard SSL certificate for you entire site collections. E.g. *.Company.com. could be used for sites such as: Sales.Crescent.com or NA.Sales.Crescent.com, etc.

So, How to Create Host-Named site collection?
Well, Create a web application with out Host header(You can create using SharePoint Central Administration or with PowerShell New-SPWebApplication cmd-let) , and execute the PowerShell command, Of course, Host-named site collections can be only created by using the Windows PowerShell only:

New-SPSite http://<URL-For-Site-Collection> -OwnerAlias Domain\username -HostHeaderWebApplication <Web-App-URL>
This creates a host-named site collection with the URL <URL-For-Site-Collection> in the SharePoint 2010 Web Application with the URL <Web-App-URL>.
To Change URL of the Host Named site collections, use: Stsadm -o RenameSite. E.g.
stsadm -o renamesite -oldurl "http://intranet.crescent.com/" -newurl "http://portal.crescent.com"
Don't forget to update IIS!

Add IIS Binding:
Don't forget to add IIS bindings! Otherwise, your host named site collections will not be accessible. Go to IIS, Pick the Web Applications which hosts the Host Named Site collection, Click on Bindings,  Add the Host header URLs of Host Named site collections.
Host Named Site Collections in SharePoint
Its also possible to add site bindings from PowerShell. Here is the script:
Import-Module WebAdministration
New-WebBinding -Name "<Web Site Name in IIS>" -Port 80 -Protocol http -HostHeader "prod.crescent.com"

Technet Reference on Host-named site collections: Plan for host-named site collections

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


Thursday, July 14, 2011

Build SharePoint 2010 Farm without Database GUIDs

When setting up SharePoint, often its a annoyance from DBAs perspective, SharePoint adds GUIDs with Database names.
Build SharePoint 2010 without Database GUIDs

Is there a way to build with out GUIDs? Yes, PowerShell is your Friend. Here is how:

For Configuration Database:
Once the installation is over, un-check the “Run Product & technologies configuration wizard” check box. Fire the powershell for SharePoint, and enter the below commands:

New-SPConfigurationDatabase -DatabaseName SP2010_Farm_Config -DatabaseServer <Database Server Name> -AdministrationContentDatabaseName SP2010_Farm_AdminContent

You can use the above PowerShell commands to build a Standalone SharePoint 2010 environment with Local user account!

When prompted for user name password: Enter Domain\username. once completed, run the Products and technologies configuration wizard!


Configure the Search Service application

#Set the initial variables.
$Search_Service_name = "Search Service Application"
$Search_Service_account = "G1vsptst01\Administrator"
$Search_Service_Instance = get-spenterprisesearchserviceinstance -local

# Start Services search services for Search Service Application
Start-SPEnterpriseSearchServiceInstance -Identity $Search_Service_Instance

# Create an Application Pool.
$AppPool = new-SPServiceApplicationPool -name "Search Service App Pool" -account $Search_Service_account

# Create the SearchApplicationlication and set it to a variable
$SearchApplication = New-SPEnterpriseSearchServiceApplication -Name $Search_Service_name -applicationpool $AppPool -databasename "SP2010_Farm_SearchService"

# Create search service application proxy
$Search_Service_Proxy = new-spenterprisesearchserviceapplicationproxy -name "SearchApplicationProxy" -Uri $SearchApplication.Uri.AbsoluteURI

# Provision Search Admin Component.
set-SPenterprisesearchadministrationcomponent -SearchApplication $SearchApplication  -searchserviceinstance $Search_Service_Instance

Now, From this point on you can configure the index and Crawl components from central admin.

For Web Analytics
#Web Analytics Service and Proxy

$saAppPool = Get-SPServiceApplicationPool -Identity "Service Application App Pool" -EA 0

$stagerSubscription = ""
$reportingSubscription = ""

New-SPWebAnalyticsServiceApplication -Name "Web Analytics Service Application" -ApplicationPool $saAppPool -ReportingDataRetention 20 -SamplingRate 100 -ListOfReportingDatabases $reportingSubscription -ListOfStagingDatabases $stagerSubscription > $null

New-SPWebAnalyticsServiceApplicationProxy -Name "Web Analytics Proxy" -ServiceApplication "Web Analytics Service Application" > $null
Get-SPServiceInstance | where-object {$_.TypeName -eq "Web Analytics Web Service"} | Start-SPServiceInstance > $null
Get-SPServiceInstance | where-object {$_.TypeName -eq "Web Analytics Data Processing Service"} | Start-SPServiceInstance > $null

Update:
http://autospinstaller.codeplex.com/ makes everything simpler! give it a try!!

More Info:
http://msmvps.com/blogs/shane/archive/2010/10/26/getting-rid-of-guids-in-sharepoint-2010-database-names.aspx
http://todd-carter.com/post/2010/04/26/The-Wizard-Likes-His-GUIDs.aspx

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


Tuesday, July 12, 2011

How to Hide User Names in Created by, Modified by Fields in SharePoint

Requirement:  Had to provide complete anonymous entries in SharePoint task list by masking user names (as in SharePoint Surveys).

Here is the Trick: There is a Property for SharePoint List, called "ShowUser". we can set that to "False" using PowerShell or C# object model.

PowerShell script to Hide User Names in SharePoint:
$SPweb=Get-SPWeb "http://sharepoint"
$SPlist=$SPweb.Lists["Tasks"]
$SPlist.ShowUser=$false
$SPlist.Update()
sharepoint hide user name


and here is the effect in action:

sharepoint mask user names

For SharePoint 2007 Hide User Name:
For MOSS 2007, You can do the same using C# code (PowerShell also possible!)

namespace HideUserInfo
{
    class HideUserInfo
    {
        static void Main(string[] args)
        {

            using (SPSite oSPSite = new SPSite("http://SharePoint.com"))  //Site collection URL
            {
                using (SPWeb oSPWeb = oSPSite.OpenWeb("News"))  //Subsite URL
                {
                    SPList oSPList = oSPWeb.Lists["Pages"];   //List/Library Name
                    oSPList.ShowUser = false;
                    oSPList.Update();
                }
            }
        }
    }
}


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


Thursday, July 7, 2011

SharePoint Datasheet view in Read-only mode ? Try these Solutions


Issue: In Datasheet sheet view, users unable to edit anything. Its in always Read-Only mode.
sharepoint datasheet view read only

Solution:
Check the following to fix SharePoint list in datasheet view is read only:
  1. Content Approval must be turned OFF 
Microsoft KB: http://support.microsoft.com/kb/2274841

     2.  Some of the columns are dependent on the Microsoft Access, Check whether MS-Access is installed in client machine.
     3.  Check whether you have permission to edit
     4.  The document in the current row may be checked out by a user.
     5. Attachments are read-only in a list that requires content approval. You cannot view or edit attachments in any of the views.
     6.  Certain columns, such as Created By and Modified, are always read-only.
     7.  There may be an unresolved conflict or error in the selected row or column. Resolve the conflict or error before attempting to edit the selected row or column.

Update: To use edit in Datasheet view, even with content approval turned ON, use my trick Edit in Datasheet View - Even When Content Approval is Turned ON

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


Friday, July 1, 2011

Opening/Saving Documents in SharePoint is Very Slow - Solution

Recently, an end user reported the issue: Opening/Saving Office 2007 Documents to MOSS 2007 is very Slow.  Here is his detailed complaint:

"Often at work, I sometimes receive a message after 10 minutes or so that 'Excel Is not responding' in the upper corner of the screen. When this happens, the document is not saved and I must reopen it and make the same changes again. It does not always appear to be able to recover.

When I am waiting on a document to save or load, I cannot move to another Excel document even if it was open at that time. Even when I do a 'save as' to save to my C drive, it takes forever.

It is very frustrating not to be able to have documents available when needed. I cannot give quick responses when am asked for information. Can you please help?"

Here is the simple fix for these kind of issues:
  1. Open up Internet Explorer
  2. Go to Tools > Internet Options 
  3. Click the Connections Tab > then click the LAN Settings button
  4. Uncheck the option "Automatically Detect Settings" 
  5. Click OK through all the dialog boxes to save your settings
  6. Close and re-open your Internet Explorer
Opening/Saving Office 2007 Documents to MOSS 2007 is very Slow


That's it.

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