Translate

Thursday, August 21, 2014

PS Script to do the sizing which includes all versions

#-----------------------------------
cls
if ( (Get-PSSnapin -Name Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue) -eq $null )
{
Add-PsSnapin Microsoft.SharePoint.PowerShell
}
$ErrorActionPreference="SilentlyContinue"
Stop-Transcript | out-null
$ErrorActionPreference = "Continue"
Start-Transcript -path C:\outputsize.txt -append
function GetWebSize ($Web)
{
[long]$subtotal = 0
foreach ($folder in $Web.Folders)
{
$subtotal += GetFolderSize -Folder $folder
}
$sitetotal=$subtotal
$SiteInGb = (($sitetotal/1024)/1024)/1024
$SiteInGb = "{0:N4}" -f $SiteInGb
write-host "," $Web.Url "," $SiteInGb ","
write-host "`r`n"
return $subtotal
function GetSubWebSizes ($Web)
{
[long]$subtotal = 0
foreach ($subweb in $Web.GetSubwebsForCurrentUser())
{
[long]$webtotal = 0
foreach ($folder in $subweb.Folders)
{
$webtotal += GetFolderSize -Folder $folder
}
$subsitetotal=$webtotal
$subsiteInGb = (($subsitetotal/1024)/1024)/1024
$subsiteInGb = "{0:N4}" -f $subsiteInGb
write-host "," $subweb.Url "," $subsiteInGb ","
write-host "`r`n"
$subtotal += $webtotal
$subtotal += GetSubWebSizes -Web $subweb
}
return $subtotal
function GetFolderSize ($Folder)
{
[long]$folderSize = 0
foreach ($file in $Folder.Files)
{
if ($file.Versions -ne $NULL -and $file.Versions.Count -gt 1) {
foreach ($version in $file.Versions)
{
$folderSize += $version.Size;
}
}
else {
$folderSize += $file.Length;
}
}
foreach ($fd in $Folder.SubFolders)
{
$folderSize += GetFolderSize -Folder $fd
}
return $folderSize
}

$web = Get-SPWeb $args[0]
[long]$total = 0
$total += GetWebSize -Web $web
$total += GetSubWebSizes -Web $web
$totalInMb = ($total/1024)/1024
$totalInMb = "{0:N4}" -f $totalInMb
$totalInGb = (($total/1024)/1024)/1024
$totalInGb = "{0:N4}" -f $totalInGb
write-host "Total size of all sites below" $StartWeb "is" $total "Bytes,"
write-host "which is" $totalInMb "MB or" $totalInGb "GB"
$web.Dispose()
Stop-Transcript
#--------------------------------------------
To run the above PowerShell - first copy the above code and save in a file with anyname.PS1 and fireup the PowerShell with administrator 
# how to run this script -
c:\>anyname.ps1 http://portal/
OR
c:\>anyname.ps1 http://portal/portal1
OR
c:\>anyname.ps1 http://portal/portal1/portal2


Monday, August 18, 2014

An SPRequest object was not disposed before the end of this thread.

An SPRequest object was not disposed before the end of this thread.  To avoid wasting system resources, dispose of this object or its parent (such as an SPSite or SPWeb) as soon as you are done using it.  Due to flags specified at object creation, this will not be freed until processed by garbage collection.  Allocation Id: {D7B164AB-A421-46AC-80C6-D119DBE511BB}  To determine where this object was allocated, set Microsoft.SharePoint.Administration.SPWebService.ContentService.CollectSPRequestAllocationCallStacks = true.


Solution - Related web application pool stop and start again and it works fine for me :)

Thursday, August 14, 2014

Dissecting the Office Web Apps cache in SharePoint 2010

http://www.wictorwilen.se/Post/Dissecting-the-Office-Web-Apps-cache-in-SharePoint-2010.aspx

http://blogs.catapultsystems.com/IT/archive/2010/08/26/co-authoring-in-sharepoint-2010-explained.aspx

Tuesday, August 12, 2014

Recommended SharePoint Related Tools

Recommended SharePoint Related Tools

http://gallery.technet.microsoft.com/The-SharePoint-Flavored-5b03f323    This link is external to TechNet Wiki. It will open in a new window. , the SharePoint Flavored Weblog Reader (SFWR) helps troubleshooting performance problems by analyzing the IIS log files of SharePoint WFEs.
http://gallery.technet.microsoft.com/PressurePoint-Dragon-for-87572ee1 This link is external to TechNet Wiki. It will open in a new window.  , PressurePoint Dragon for SharePoint 2013 helps executing performance tests.
http://gallery.technet.microsoft.com/Maxer-for-SharePoint-2013-52208636 This link is external to TechNet Wiki. It will open in a new window.  , a tool for checking capacity planning limits.
http://visualstudiogallery.msdn.microsoft.com/36a6eb45-a7b1-47c3-9e85-09f0aef6e879    This link is external to TechNet Wiki. It will open in a new window. , Muse.VSExtensions, a great tool for referencing assemblies located in the GAC.
http://www.quest.com/powergui-freeware/ This link is external to TechNet Wiki. It will open in a new window.  , helps with all your PowerShell development. In a SharePoint environment, there usually will be some.
http://powerguivsx.codeplex.com/ This link is external to TechNet Wiki. It will open in a new window.  , Visual Studio extension based on PowerGUI that adds PowerShell IntelliSense support to Visual Studio.
http://visualstudiogallery.msdn.microsoft.com/4784e790-32f4-455f-9228-53f537c03787 This link is external to TechNet Wiki. It will open in a new window.  , FishBurn Systems provides some sort of CKSDev lite for VS.NET 2012/SharePoint 2013. Very useful.
http://visualstudiogallery.msdn.microsoft.com/6ed4c78f-a23e-49ad-b5fd-369af0c2107f This link is external to TechNet Wiki. It will open in a new window.  , web extensions make creating CSS in VS.NET a lot easier and supports CSS generation for multiple platforms.
http://technet.microsoft.com/en-us/library/cc508851 This link is external to TechNet Wiki. It will open in a new window. , the SharePoint 2010 Administration Toolkit (works on 2013).
http://clumsyleaf.com/products/cloudxplorer This link is external to TechNet Wiki. It will open in a new window.  , a great tool when you've installed your SharePoint farm on Azure.

Feature upgrade incomplete for Feature 'PublishingWeb' (Id: '94c94ca6-b32f-4da9-a9e3-1f3d343d7ecb') in Web. Exception: A duplicate content type name "Resource" was found.

When the SharePoint Server Publishing Infrastructure is activated it creates this hidden list automatically. 

This list is hidden and can be accessed by going to this URL: http://portalsite/relationships%20list/allitems.aspx. What happens here since the SharePoint Server Publishing Infrastructure feature is already activated in the SP2007 environment and then moved over to SP2010 via DB attachment there is a conflict with a column in that list called GroupGuid.

In SharePoint 2007 the column name is GroupId and is type text, and is changed in SharePoint 2010 to GroupGuid with the same type text. For whatever reason this column type is not updated when migrated over. This column type needs to be set at GUID not text. Since there is no way within SharePoint to create a column with a GUID type the best way to fix the problem is to delete this list and have it automatically re-created. 

To successfully delete this list follow these steps.
1. Go to Site Actions, Site Settings and Site Collection features under Site Collection Administration.
2. Deactivate the SharePoint Server Publishing Infrastructure feature
3. Go back to http://portalsite/relationships%20list/allitems.aspx
4. Go to List, List Settings and Delete this list (If the SharePoint Server Publishing Infrastructure feature is not deactivated this option will not be visible)
5. After deleting the list go back to Site Actions, Site Settings, and Site Collection features
6. Activate SharePoint Server Publishing Infrastructure feature

Column Limit Exceeded

There are too many columns of the specified data type. Please delete some other columns first. Note that some column types like numbers and currency use the same data type.
when trying to reactivate this feature read this blog posting -
7. The SharePoint Server Publishing Infrastructure feature will automatically recreate the list.
Go back to http://portalsite/relationship%20list/allitems.aspx and verify that the column GroupGuid now has a column of type GUID instead of text.
            Now go back to the site you were trying to access and you should no longer get that error message                   “One or more field types are not installed properly. Go to List settings page to delete these                   fields

Poweshell - Get the list of all template files or layout pages

Not interested in writing big story for small things  :)

List all the template files for given content SharePoint content database -

stsadm.exe -o enumallwebs -databasename <contentdbname>  > c:\template.txt

=====================================
List all page layouts -

$web = get-spweb http://yoursite
$pubWeb = [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($web)
$pubWeb.GetAvailablePageLayouts() | select Name

List of all master pages for all web apps

Method 1
Get-SPWebApplication | Get-SPSite -Limit All | Get-SPWeb -Limit All | Select Title, URL, MasterUrl | Export-CSV C:\allmasterpage.csv

Method 2
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
#Get All site collections
$SiteCollections = Get-SPWebApplication | Get-SPSite -Limit All
#Loop through all site collections
   foreach($Site in $SiteCollections)
    {
        #Loop throuh all Sub Sites
       foreach($Web in $Site.AllWebs)
       {
      $MasterPage = $Web.GetFile($Web.MasterUrl);
          $MasterPage.Name  +" : " +$Web.Url
       }
    }
     

SharePoint - Various way to get the size at the site collection and its various level

We have many times the requirement to get the size at various level in SharePoint – Hope the below information will help you !!

SharePoint Designer –

Specific feature of it – the ability to view the storage used for an entire site collection!

If you open up SharePoint Designer to the root site of your site collection, in the main window, once the site is opened under Site Information, that it will conveniently display the Total Storage Used of your entire site collection!

StorMan.aspx –

SharePoint 2010
Go to Site Actions -> Site Settings -> Site Collection Administration -> Storage Metrics, this will give you details on the usage – such as what sites, lists, libraries, and items are taking up the most space, however, it will not give you a total like our trusty SharePoint Swiss Army Knife – SharePoint Designer does, but, it will allow you to drill down into the usage.

PowerShell
$site = Get-SPSite http://my.sitecollection.com
$site.Usage;
$site.Dispose();

$site = Get-SPSite http://my.sitecollection.com
$site.Usage.Storage;
$site.Dispose();

Web Analytics
Go to Site Actions -> Site Settings -> Site Actions -> Site Collection Web Analytics reports

Once there, in the main screen, you can view a summary of the Total Storage Used under Inventory

And if you click on Storage Usage under Inventory within the quick launch navigation on the left, you can then view reports on storage utilization for your site collection, with a graph of the values so you can easily visualize the trend in storage usage.

You can also run reports for any date range since Web Analytics have been enabled, as well as run workflows against this data for alerting and reporting.

How to Restore from Unattached Content Database - Step by Step

1.Restore content database to a temporary location. Backup file is not enough, to use the unattached content database recovery you need the database mounted on a SQL server. This can be the same SQL instance used by SharePoint, or a different SQL box. If you restore into the same SQL instance make sure you (or your SQL DBA’s) use a different name for the restored database and don’t override the production content! Note the name of the SQL Server instance and the name of the database copy.

2.Go to SharePoint Central Administration, navigate to Backup and Restore and click the “Recover data from an unattached content database” link under Granular Backup.

3.Type the SQL Instance and temporary database names and specify what you want to do. Note that none of the available options actually allows you to restore a document, you can either create a backup of site collection or export a site or list. If you only need a single document, you’ll need to export the library in order to get it.

4.Select site collection, site and list to export. In this step you also specify the name for the export file and the export options, such as whether security and versions should be included in the export. You are ready to start the export.

5.Thank you ! you have completed the Unattached Content Database Recovery now! Wait, did you actually need that document? All you have is the export.cmp file, where to look next? There is no import available in the Central Administration UI. So what do you do next?

6.Start the SharePoint Management Shell, which is PowerShell with Microsoft.SharePoint.PowerShell snap-in already loaded. Then use the Import-SPWeb cmdlet to import the library. It is important to understand you cannot restore list or library under a different name. If a document library with the same name already exists in the destination site, import will merge contents and by default create new document versions where possible.

7.Finally, browse to the imported library and get the document you just restored. Once this is done, you can safely delete the imported document library from SharePoint, and delete the temporary database from SQL server.

Best practices and use of SP 2010 functionality for restoring SITE/SITE Collection

Procedure for restoring a site pre-SP1

Restore entire farm from backup.

Drawbacks: Time consuming, costly and sometimes complete failure.

Procedure for restoring a site post-SP1

1.       Ensure user is a site collection administrator
2.       Go to Site Actions –&gt; Site Actions
3.       Click Site Collection Administration
4.       Click Recycle Bin
5.       Check the site you want to restore and click Restore.

Quick and simple, isn’t it?

In Microsoft SharePoint Server 2010 w/ SP1, a deleted site is not permanently deleted, but moved to the 2nd stage Recycle Bin. The default setting for automatic deletion is 30 days – however, this is modifiable. You can see how to do these changes here -

http://technet.microsoft.com/en-us/library/cc263125.aspx

Restoring whole Site Collections -

You can use the following PowerShell cmdlets to restore, delete or view deleted site collections:
•         Get-SPDeletedSite - http://technet.microsoft.com/en-us/library/hh286316.aspx
•         Remove-SPDeletedSite - http://technet.microsoft.com/en-us/library/hh286317.aspx
•         Restore-SPDeletedSite - http://technet.microsoft.com/en-us/library/hh286319(v=office.15).aspx

Hope this above information will help you to understand the new functionality and benefits

Content Inventory - Powerful PS

Get-SPWebApplication http://changeweburl.com/ | Get-SPSite -Limit All | Get-SPWeb -Limit All | Select Title, URL | Export-CSV C:\changefilename.csv -NoTypeInformation - This is inventory of all the URLs with Title and URL


Get-SPWeb http://changeweburl/changesite1/changesub-site/ | Select -ExpandProperty Lists | Where { $_.GetType().Name -eq "SPDocumentLibrary" -and  -not $_.Hidden } | Select -ExpandProperty Items | Select Name, url, {$_["Created By"]}, {$_["Modified"]} | Export-CSV C:\changefilename.csv - Content Inventory at sub-site level

Debugging/Troubleshooting Office Web Apps

Debugging

Use WireShark to capture traffic on the SharePoint server.
Use a Text Differencing tool to compare if web.config files on WFEs are identical.
Use Fiddler to monitor web traffic using the People Picker. This will provide insight in how to use the people picker for custom development. Please note: the client People Picker web service interface is located in SP.UI.ApplicationPages.ClientPeoplePickerWebServiceInterface.

Troubleshooting Office Web Apps
http://social.technet.microsoft.com/wiki/contents/articles/16640.sharepoint-2013-tips-for-troubleshooting-search-suggestions.aspx , troubleshooting search suggestions.
http://technet.microsoft.com/en-us/library/jj906556.aspx This link is external to TechNet Wiki. It will open in a new window.  , troubleshooting claims authentication.
http://technet.microsoft.com/en-us/library/dn169566.aspx This link is external to TechNet Wiki. It will open in a new window.  , troubleshooting fine grained permissions.
http://social.technet.microsoft.com/Forums/sharepoint/en-US/02b78299-bc7f-448b-b233-f9cae0da8466/sharepoint-2013-alerts-are-not-firing-any-mails-for-the-normal-alerts-and-search-alerts-can-someone , troubleshooting email alerts.

Upgrade and Migration

http://blogs.msdn.com/b/russmax/archive/2013/04/01/why-sharepoint-2013-cumulative-update-takes-5-hours-to-install.aspx?CommentPosted=true#commentmessage This link is external to TechNet Wiki. It will open in a new window. Why SharePoint 2013 Cumulative Update takes 5 hours to install, improve CU (patch) Installation times from 5 hours to 30 mins.
http://social.technet.microsoft.com/wiki/contents/articles/15743.sharepoint-2013-best-practices-upgrading-from-sharepoint-2007.aspx discusses best practices for upgrading from SharePoint 2007 to 2013.
http://social.technet.microsoft.com/wiki/contents/articles/16033.sharepoint-2013-best-practices-migrate-from-sharepoint-foundation-2013-to-sharepoint-server-2013.aspx , upgrade SharePoint Foundation 2013 to SharePoint Server 2013.
http://technet.microsoft.com/en-us/library/cc262483.aspx This link is external to TechNet Wiki. It will open in a new window.  , SharePoint 2010 to 2013.
http://technet.microsoft.com/en-us/library/cc303436.aspx This link is external to TechNet Wiki. It will open in a new window.  , upgrade databases from SharePoint 2010 to 2013.
http://technet.microsoft.com/en-us/library/ee947141.aspx This link is external to TechNet Wiki. It will open in a new window.  , upgrade from sharepoint 2007 or wss 3 to sharepoint 2013.