Wednesday, September 4, 2013

SPSite.usage returning null or zero

Here is the small issue i faced and found the solution after 4 hours struggle.

Scenario : I came accross a requirement create a powershell script to get the site usage in MB for all the site collections in a web application.

Below is the code to get the same :

$usage = $spSite.usage.storage/1MB

Issues : when i ran the above script most of the site collections the it is returning null / zero. When i check the same using STSADM enumsites command it is again diffarent.

Solution : Log off from the server re login as farm administrator account.


Conclusion : Farm administrator who has full control on all the SQL, SharePoint can only be allowed to pull the information.

SharePoint Programatically get site quota template name

Here is the script to get the site collection quota template details using powershell.

$contentService = [Microsoft.SharePoint.Administration.SPWebService]::ContentService

$quotaTemplate = $contentService.QuotaTemplates | where {$_.QuotaID -match $spSite.Quota.QuotaID}

write-host $quotaTemplate.Name
  
Thank you !!! 

powershell script relative path


Here is the sample code to get the relative path of the powershell script which will help to make consistency when you run script files in multiple environments.

function scriptDirectory()
{
   $path = ""
   $path = [IO.Path]::GetFullPath((join-path $MyInvocation.ScriptName ".\.."))
   return $path
}


The above function will return the script file path as a string value.

One or more field types are not installed properly. Go to List settings page to delete these fields. Error while viewing Manage Content and Structure Page

In SharePoint 2010 publishing site,  when you go to Site Settings -> Manage Content and Structure menu, you will get an error message saying One or more field types are not installed properly. Go to List settings page to delete these fields with an associated correlation ID.

Root cause :
  • The publishing site uses SharePoint Server Publishing Infrastructure to support the publishing features in SharePoint.
  • This feature automatically creates an internal List “Relationships List” which is used to store the variations details.
  • This list is normally not visible in View All Site Content menu but you can browse it through the url http://site_url/Relationships%20List/allitems.aspx.
  • The actual issue is after migration of the site, the list will have a column GroupId which is of type Text. But actually it should be GroupGuid with type as GUID.
  • So we need to resolve this column name & type inconsistency.
Solution for the Issue :
  • You will not be able to delete and re-create the column since SharePoint doesn’t support creation of column of type GUID through UI.
  • So only way is to delete and re-create the list.
  • Go to Site Settings -> Modify All Site Settings -> Site Collection Features and deactivate SharePoint Server Publishing Infrastructure feature.
  • This removes the association between the feature and the Relationships list, which allows you to delete the list.
  • Navigate to the URL http://site_url/Relationships%20List/allitems.aspx and delete the list from the list settings.
  • Now go to site collection features and activate the SharePoint Server Publishing Infrastructure feature.
  • Note that Relationships list will be created automatically. You can check the same by navigating to the URL as states above.
  • You can check the list containing the column GroupGuid of type GUID.
Now check your Manage Content and Structure page which will be working fine. Hope it helps

Please refer to the actual post on this issue from this blog

Thank you !!


SharePoint Create new site One or more field types are not installed properly. Go to List settings page to delete these fields

Here is the issue usually comes when you migrate sites from 2007 to 2010 using SPContentDatabase mount operation.

This issue is an intermittent and not exists for all the site collections and not sure about why investigating more on this.


Root cause :
  • The publishing site uses SharePoint Server Publishing Infrastructure to support the publishing features in SharePoint.
  • This feature automatically creates an internal List “Relationships List” which is used to store the variations details.
  • This list is normally not visible in View All Site Content menu but you can browse it through the url http://site_url/Relationships%20List/allitems.aspx.
  • The actual issue is after migration of the site, the list will have a column GroupId which is of type Text. But actually it should be GroupGuid with type as GUID.
  • So we need to resolve this column name & type inconsistency.
Solution for the Issue :
  • You will not be able to delete and re-create the column since SharePoint doesn’t support creation of column of type GUID through UI.
  • So only way is to delete and re-create the list.
  • Go to Site Settings -> Modify All Site Settings -> Site Collection Features and deactivate SharePoint Server Publishing Infrastructure feature.
  • This removes the association between the feature and the Relationships list, which allows you to delete the list.
  • Navigate to the URL http://site_url/Relationships%20List/allitems.aspx and delete the list from the list settings.
  • Now go to site collection features and activate the SharePoint Server Publishing Infrastructure feature.
  • Note that Relationships list will be created automatically. You can check the same by navigating to the URL as states above.
  • You can check the list containing the column GroupGuid of type GUID.
Now check your Manage Content and Structure page which will be working fine. Hope it helps

Please refer to the actual post on this issue from this blog

Thank you !!

Error Deleting Site Collection The system cannot find the path specified

Here is the interesting issue i came across while doing some migrations.

Post migration when i try to delete site collections from SP 2007 envionment, I deleted a site collection which is huge in size the operation went for such a long time and finally resulted failure to delete the site collection.

After that when i see the site collection from CA i see the site collection listed in CA but none of the properties for the site collection were listed there like Title, URL, Description, Database name.
All the above properties were empty.

An error like this prevents you from upgrading SharePoint aswell, because you won't be able to access the site collection either

Root cause :  The site collection deleted from content database but some references still there in database.

Solution :

1. Execute database repair command : 

Execute the following two commands one after one.

STSADM.EXE -o databaserepair -url "url of the application" -databasename "Name of the DB" >"C:\Result.txt"

STSADM.EXE -o databaserepair -url "url of the application" -databasename "Name of the DB" -deletecorruption

First command should result as <OrphanedObjects Count="0" />

2. Delete and add Content DB : 

To resolve the error, detach and attach the content database of the afflicted site collection.

stsadm -o deletecontentdb -databasename "DB name" -url "site collection url"

stsadm -o addcontentdb -databasename "DB name" -url "site collection url" 

NOTE : Executing above script will not delete anything in the content database except the issue causing things or partially deleted site collections.

After this you can go and check in CA and found the site collections deleted completely. 

Thank you !!!