Powershell Mount and dismount content database

While working on the scripts for dismounting all content database for a DR situation found SPContentdatabase do not display OFFLINE databases. So had to work around to get the offline content database for each web application and disable it.

Code

Puts OFFLINE AND DISMOUNT all attached DBs

get-spwebapplication -identity webappURL | foreach {$SPContentDB = $_.ContentDatabases}

$SPContentDB | ForEach {Set-SPContentDatabase -Identity $_ -status disabled}

$SPContentDB | ForEach {Dismount-SPContentDatabase $_ -confirm:$false}

Found another interesting blog where it mentioned putting SharePoint content database offline is no the best practice rather putting the sitecollection max count to current number of sitecollections also avoids creating new sitecollection for the specified content database.

MOUNT DATABASE

mount-spcontentdatabase “DBName” -DatabaseServer “DBServer” -Webapplication webappURL

Red: http://msmvps.com/blogs/shane/archive/2011/04/28/powershell-doesn-t-show-all-of-your-sharepoint-2010-content-databases.aspx

IncludeExceptionDetailInFaults Error message Sharepoint 2010

The server was unable to process the request due to an internal error. For more information about the error, either turn on IncludeExceptionDetailInFaults (either from ServiceBehaviorAttribute or from the <serviceDebug> configuration behavior) on the server in order to send the exception information back to the client, or turn on tracing as per the Microsoft .NET Framework 3.0 SDK documentation and inspect the server trace logs.

To get the actual error:

INETMGR –> SharePoint Web Services –> Right Click Explore Security Token ServiceApplication –> Edit Web Config and add

<serviceDebug httpHelpPageEnabled=”true” includeExceptionDetailInFaults=”true” />   

below <serviceThrottling maxConcurrentCalls=”65536″ maxConcurrentSessions=”65536″ maxConcurrentInstances=”65536″ />

 

SharePoint quota email has empty data

When SharePoint site collection exceeds the quota limit it sends the email to the owner. But in our environment the email has URL to _layouts/usage.aspx where the data are all empty. But the web analytic report has all data populated.

After research found out the there are 2 timer jobs for the usage analysis. 1) for data gathering and other for data processing. For some reason our processing time job email was disabled.

In Central Administration, on the Home page, click Monitoring.

On the Monitoring page, in the Reporting section, click Configure usage and health data collection.

On the Configure usage and health data collection page, in the Usage data collection section, enable usage data collection by selecting the Enable usage data collection text box.

In the Event Selection section, select the events to log by selecting the check box next to the events in the Events to log list

In the Usage data collection settings section, type the path of the folder you want usage and health information to be written to in the Log file location box. The path that you specify must exist on all farm servers.

Type the maximum disk space for the logs in gigabytes (between 1 and 20 GB) in the Maximum log file size box.

In the Health data collection section, select the Enable health data collection check box. To change the collection schedules, click Health Logging Schedule. A list of timer jobs that collect health data is listed. Click any of the timer jobs to change its schedule, or disable that timer job.

ref:msdn

But the main part was on Log Collection Schedule Click the log colletion schedule it will take to the page with 2 timer jobs that I mentioned before. Activate both the jobs and run it.

Now _layouts/usage.aspx will have valid data in it.

 

Document and List Fields Internal name

For a
standard Document Library the fields are….

Display Name Internal Name GUID Type
ID ID {1d22ea11-1e32-424e-89ab-9fedbadb6ce1} Counter
Content Type ID ContentTypeId {03e45e84-1992-4d42-9116-26f756012634} ContentTypeId
Content Type ContentType {c042a256-787d-4a6f-8a8a-cf6ab767f12d} Text
Created Created {8c06beca-0777-48f7-91c7-6da68bc07b69} DateTime
Created By Author {1df5e554-ec7e-46a6-901d-d85a3881cb18} User
Modified Modified {28cf69c5-fa48-462a-b5cd-27b6f9d2bd5f} DateTime
Modified By Editor {d31655d1-1d5b-4511-95a1-7a09e9b75bf2} User
Has Copy
Destinations
_HasCopyDestinations {26d0756c-986a-48a7-af35-bf18ab85ff4a} Boolean
Copy Source _CopySource {6b4e226d-3d88-4a36-808d-a129bf52bccf} Text
Approval Status _ModerationStatus {fdc3b2ed-5bf2-4835-a4bc-b885f3396a61} ModStat
Approver Comments _ModerationComments {34ad21eb-75bd-4544-8c73-0e08330291fe} Note
URL Path FileRef {94f89715-e097-4e8b-ba79-ea02aa8b7adb} Lookup
Path FileDirRef {56605df6-8fa1-47e4-a04c-5b384d59609f} Lookup
Modified Last_x0020_Modified {173f76c8-aebd-446a-9bc9-769a2bd2c18f} Lookup
Created Created_x0020_Date {998b5cff-4a35-47a7-92f3-3914aa6aa4a2} Lookup
File Size File_x0020_Size {8fca95c0-9b7d-456f-8dae-b41ee2728b85} Lookup
Item Type FSObjType {30bb605f-5bae-48fe-b4e3-1f81d9772af9} Lookup
Effective
Permissions Mask
PermMask {ba3c27ee-4791-4867-8821-ff99000bac98} Computed
ID of the User who
has the item Checked Out
CheckedOutUserId {a7b731a3-1df1-4d74-a5c6-e2efba617ae2} Lookup
Is Checked out to
local
IsCheckedoutToLocal {cfaabd0f-bdbd-4bc2-b375-1e779e2cad08} Lookup
Checked Out To CheckoutUser {3881510a-4e4a-4ee8-b102-8ee8e2d0dd4b} User
Name FileLeafRef {8553196d-ec8d-4564-9861-3dbe931050c8} File
Unique Id UniqueId {4b7403de-8d94-43e8-9f0f-137a3e298126} Lookup
ProgId ProgId {c5c4b81c-f1d9-4b43-a6a2-090df32ebb68} Lookup
ScopeId ScopeId {dddd2420-b270-4735-93b5-92b713d0944d} Lookup
Virus Status VirusStatus {4a389cb9-54dd-4287-a71a-90ff362028bc} Lookup
Checked Out To CheckedOutTitle {9d4adc35-7cc8-498c-8424-ee5fd541e43a} Lookup
Check In Comment _CheckinComment {58014f77-5463-437b-ab67-eec79532da67} Lookup
Checked Out To LinkCheckedOutTitle {e2a15dfd-6ab8-4aec-91ab-02f6b64045b0} Computed
Document Modified
By
Modified_x0020_By {822c78e3-1ea9-4943-b449-57863ad33ca9} Text
Document Created By Created_x0020_By {4dd7e525-8d6b-4cb4-9d3e-44ee25f973eb} Text
File Type File_x0020_Type {39360f11-34cf-4356-9945-25c44e68dade} Text
HTML File Type HTML_x0020_File_x0020_Type {0c5e0085-eb30-494b-9cdd-ece1d3c649a2} Text
Source Url _SourceUrl {c63a459d-54ba-4ab7-933a-dcf1c6fadec2} Text
Shared File Index _SharedFileIndex {034998e9-bf1c-4288-bbbd-00eacfc64410} Text
Edit Menu Table
Start
_EditMenuTableStart {3c6303be-e21f-4366-80d7-d6d0a3b22c7a} Computed
Edit Menu Table End _EditMenuTableEnd {2ea78cef-1bf9-4019-960a-02c41636cb47} Computed
Name LinkFilenameNoMenu {9d30f126-ba48-446b-b8f9-83745f322ebe} Computed
Name LinkFilename {5cc6dc79-3710-4374-b433-61cb4a686c12} Computed
Type DocIcon {081c6e4c-5c14-4f20-b23e-1a71ceb6a67c} Computed
Server Relative URL ServerUrl {105f76ce-724a-4bba-aece-f81f2fce58f5} Computed
Encoded Absolute
URL
EncodedAbsUrl {7177cfc7-f399-4d4d-905d-37dd51bc90bf} Computed
Name BaseName {7615464b-559e-4302-b8e2-8f440b913101} Computed
File Size FileSizeDisplay {78a07ba4-bda8-4357-9e0f-580d64487583} Computed
Property Bag MetaInfo {687c7f94-686a-42d3-9b67-2782eac4b4f8} Lookup
Level _Level {43bdd51b-3c5b-4e78-90a8-fb2087f71e70} Integer
Is Current Version _IsCurrentVersion {c101c3e7-122d-4d4d-bc34-58e94a38c816} Boolean
Select SelectTitle {b1f7969b-ea65-42e1-8b54-b588292635f2} Computed
Select SelectFilename {5f47e085-2150-41dc-b661-442f3027f552} Computed
Edit Edit {503f1caa-358e-4918-9094-4a2cdc4bc034} Computed
owshiddenversion owshiddenversion {d4e44a66-ee3a-4d02-88c9-4ec5ff3f4cd5} Integer
UI Version _UIVersion {7841bf41-43d0-4434-9f50-a673baef7631} Integer
Version _UIVersionString {dce8262a-3ae9-45aa-aab4-83bd75fb738a} Text
Instance ID InstanceID {50a54da4-1528-4e67-954a-e2d24f1e9efb} Integer
Order Order {ca4addac-796f-4b23-b093-d2a3f65c0774} Number
GUID GUID {ae069f25-3ac2-4256-b9c3-15dbc15da0e0} Guid
Workflow Version WorkflowVersion {f1e020bc-ba26-443f-bf2f-b68715017bbc} Integer
Workflow Instance
ID
WorkflowInstanceID {de8beacf-5505-47cd-80a6-aa44e7ffe2f4} Guid
Source Version
(Converted Document)
ParentVersionString {bc1a8efb-0f4c-49f8-a38f-7fe22af3d3e0} Lookup
Source Name
(Converted Document)
ParentLeafName {774eab3a-855f-4a34-99da-69dc21043bec} Lookup
Title Title {fa564e0f-0c70-4ab9-b863-0177e6ddd247} Text
Template Link TemplateUrl {4b1bf6c6-4f39-45ac-acd5-16fe7a214e5e} Text
Html File Link xd_ProgID {cd1ecb9f-dd4e-4f29-ab9e-e9ff40048d64} Text
Is Signed xd_Signature {fbf29b2d-cae5-49aa-8e0a-29955b540122} Boolean
Merge Combine {e52012a0-51eb-4c0c-8dfb-9b8a0ebedcb6} Computed
Relink RepairDocument {5d36727b-bcb2-47d2-a231-1f0bc63b7439} Computed

For
a standard custom list the fields are…

Display Name Internal Name GUID Type
ID ID {1d22ea11-1e32-424e-89ab-9fedbadb6ce1} Counter
Content Type ID ContentTypeId {03e45e84-1992-4d42-9116-26f756012634} ContentTypeId
Content Type ContentType {c042a256-787d-4a6f-8a8a-cf6ab767f12d} Text
Title Title {fa564e0f-0c70-4ab9-b863-0177e6ddd247} Text
Modified Modified {28cf69c5-fa48-462a-b5cd-27b6f9d2bd5f} DateTime
Created Created {8c06beca-0777-48f7-91c7-6da68bc07b69} DateTime
Created By Author {1df5e554-ec7e-46a6-901d-d85a3881cb18} User
Modified By Editor {d31655d1-1d5b-4511-95a1-7a09e9b75bf2} User
Has Copy
Destinations
_HasCopyDestinations {26d0756c-986a-48a7-af35-bf18ab85ff4a} Boolean
Copy Source _CopySource {6b4e226d-3d88-4a36-808d-a129bf52bccf} Text
owshiddenversion owshiddenversion {d4e44a66-ee3a-4d02-88c9-4ec5ff3f4cd5} Integer
Workflow Version WorkflowVersion {f1e020bc-ba26-443f-bf2f-b68715017bbc} Integer
UI Version _UIVersion {7841bf41-43d0-4434-9f50-a673baef7631} Integer
Version _UIVersionString {dce8262a-3ae9-45aa-aab4-83bd75fb738a} Text
Attachments Attachments {67df98f4-9dec-48ff-a553-29bece9c5bf4} Attachments
Approval Status _ModerationStatus {fdc3b2ed-5bf2-4835-a4bc-b885f3396a61} ModStat
Approver Comments _ModerationComments {34ad21eb-75bd-4544-8c73-0e08330291fe} Note
Edit Edit {503f1caa-358e-4918-9094-4a2cdc4bc034} Computed
Title LinkTitleNoMenu {bc91a437-52e7-49e1-8c4e-4698904b2b6d} Computed
LinkFilenameNoMenu
Title LinkTitle {82642ec8-ef9b-478f-acf9-31f7d45fbc31} Computed
Select SelectTitle {b1f7969b-ea65-42e1-8b54-b588292635f2} Computed
Instance ID InstanceID {50a54da4-1528-4e67-954a-e2d24f1e9efb} Integer
Order Order {ca4addac-796f-4b23-b093-d2a3f65c0774} Number
GUID GUID {ae069f25-3ac2-4256-b9c3-15dbc15da0e0} Guid
Workflow Instance
ID
WorkflowInstanceID {de8beacf-5505-47cd-80a6-aa44e7ffe2f4} Guid
URL Path FileRef {94f89715-e097-4e8b-ba79-ea02aa8b7adb} Lookup
Path FileDirRef {56605df6-8fa1-47e4-a04c-5b384d59609f} Lookup
Modified Last_x0020_Modified {173f76c8-aebd-446a-9bc9-769a2bd2c18f} Lookup
Created Created_x0020_Date {998b5cff-4a35-47a7-92f3-3914aa6aa4a2} Lookup
Item Type FSObjType {30bb605f-5bae-48fe-b4e3-1f81d9772af9} Lookup
Effective
Permissions Mask
PermMask {ba3c27ee-4791-4867-8821-ff99000bac98} Computed
Name FileLeafRef {8553196d-ec8d-4564-9861-3dbe931050c8} File
Unique Id UniqueId {4b7403de-8d94-43e8-9f0f-137a3e298126} Lookup
ProgId ProgId {c5c4b81c-f1d9-4b43-a6a2-090df32ebb68} Lookup
ScopeId ScopeId {dddd2420-b270-4735-93b5-92b713d0944d} Lookup
File Type File_x0020_Type {39360f11-34cf-4356-9945-25c44e68dade} Text
HTML File Type HTML_x0020_File_x0020_Type {4ef1b78f-fdba-48dc-b8ab-3fa06a0c9804} Computed
Edit Menu Table
Start
_EditMenuTableStart {3c6303be-e21f-4366-80d7-d6d0a3b22c7a} Computed
Edit Menu Table End _EditMenuTableEnd {2ea78cef-1bf9-4019-960a-02c41636cb47} Computed
Name LinkFilenameNoMenu {9d30f126-ba48-446b-b8f9-83745f322ebe} Computed
Name LinkFilename {5cc6dc79-3710-4374-b433-61cb4a686c12} Computed
Type DocIcon {081c6e4c-5c14-4f20-b23e-1a71ceb6a67c} Computed
Server Relative URL ServerUrl {105f76ce-724a-4bba-aece-f81f2fce58f5} Computed
Encoded Absolute
URL
EncodedAbsUrl {7177cfc7-f399-4d4d-905d-37dd51bc90bf} Computed
File Name BaseName {7615464b-559e-4302-b8e2-8f440b913101} Computed
Property Bag MetaInfo {687c7f94-686a-42d3-9b67-2782eac4b4f8} Lookup
Level _Level {43bdd51b-3c5b-4e78-90a8-fb2087f71e70} Integer
Is Current Version _IsCurrentVersion {c101c3e7-122d-4d4d-bc34-58e94a38c816} Boolean

Query for Sharepoint information

Query for Sharepoint information

 

T-SQL Queries to get MOSS and WSS information:

  • Top 100 documents in terms of size (latest version(s) only):
  • Top 100 most versioned documents:
  • List of unhosted pages in the SharePoint solution:
  • List of top level WSS sites and their total size, including child sites in the portal:
  • List of portal area and total number of users:
  • List of top level and sub sites in the portal and the number of users:
  • List of all portal area:
  • List of the total portal area:
  • List of all top level and sub sites in the portal:
  • List of the total top level and sub sites in the portal:
  • List of all list/document libraries and total items:
  • List of document libraries and total items:
  • List of image libraries and total items:
  • List of announcement list and total items:
  • List of contact list and total items:
  • List of event list and total items:
  • List of all tasks and total items:
  • List of all InfoPath form library and total items:
  • List of generic list and total items:

Applies To:

  • Microsoft SharePoint Portal Server 2003
  • Microsoft Windows SharePoint Services
  • Microsoft® ASP. NET 1.x, 2.x
  • Microsoft® Visual Studio® .NET 2003

 

  • Top 100 most versioned documents:
    SELECT TOP 100  Webs.FullUrl As SiteUrl,   Webs.Title ‘Document/List Library Title’,   DirName + ‘/’ + LeafName AS ‘Document Name’, 
    COUNT(Docversions.version)AS ‘Total Version’,  SUM(CAST((CAST(CAST(Docversions.Size as decimal(10,2))/1024
    As      decimal(10,2))/1024) AS Decimal(10,2)) )  AS  ‘Total Document Size (MB)’,  CAST((CAST(CAST(AVG(Docversions.Size) as decimal(10,2))/1024 As     
    decimal(10,2))/1024) AS Decimal(10,2))   AS  ‘Avg Document Size (MB)’  FROM Docs INNER JOIN DocVersions ON Docs.Id = DocVersions.Id     
    INNER JOIN Webs On Docs.WebId = Webs.Id  INNER JOIN Sites ON Webs.SiteId = SItes.Id  WHERE  Docs.Type <> 1   AND (LeafName NOT LIKE ‘%.stp’)  
     AND (LeafName NOT LIKE ‘%.aspx’)    AND (LeafName NOT LIKE ‘%.xfp’)   AND (LeafName NOT LIKE ‘%.dwp’)   AND (LeafName NOT LIKE ‘%template%’)  
    AND (LeafName NOT LIKE ‘%.inf’)   AND (LeafName NOT LIKE ‘%.css’)  
    GROUP BY Webs.FullUrl, Webs.Title, DirName + ‘/’ + LeafName  ORDER BY ‘Total Version’ desc, ‘Total Document Size (MB)’ desc
  • List of unhosted pages in the SharePoint solution:
    select Webs.FullUrl As SiteUrl,   case when [dirname] = ”   then ‘/’+[leafname]   else ‘/’+[dirname]+’/’+[leafname]  
    end as [Page Url],   CAST((CAST(CAST(Size as decimal(10,2))/1024 As      decimal(10,2))/1024) AS Decimal(10,2))  
    AS  ‘File Size in MB’  FROM     Docs INNER JOIN Webs On Docs.WebId = Webs.Id  where [type]=0   and [leafname] like (‘%.aspx’)  
    and [dirname] not like (‘%_catalogs/%’)   and [dirname] not like (‘%/Forms’)   and [content] is not null  
    and [dirname] not like (‘%Lists/%’)   and [setuppath] is not null   order by [Page Url];
  • List of top level WSS sites and their total size, including child sites in the portal:
    select FullUrl As SiteUrl,    CAST((CAST(CAST(DiskUsed as decimal(10,2))/1024 As      decimal(10,2))/1024) AS Decimal(10,2)) 
    AS  ‘Total Size in MB’  from sites   Where FullUrl LIKE ‘%sites%’ AND      fullUrl <> ‘MySite’ AND fullUrl <> ‘personal’ 
  • List of portal area and total number of users:
    select webs.FullUrl, Webs.Title,       COUNT(WebMembers.UserId) As ‘Total User’ 
    from Webs INNER JOIN WebMembers   ON Webs.Id = WebMembers.WebId  Where fullurl NOT like ‘%sites%’
    AND       fullUrl <> ‘MySite’ AND fullUrl <> ‘personal’  Group BY webs.FullUrl,  Webs.Title  Order By  ‘Total User’ desc
  • List of top level and sub sites in the portal and the number of users:
    select  webs.FullUrl ,Webs.Title, COUNT(WebMembers.UserId) As ‘Total User’ 
    from Webs INNER JOIN WebMembers   ON Webs.Id = WebMembers.WebId  where fullurl  like ‘%sites%’
    AND fullUrl <> ‘MySite’ AND fullUrl <> ‘personal’  Group BY webs.FullUrl,  Webs.Title  Order By  ‘Total User’ desc
  • List of all portal area:
    select Webs.FullUrl As [Site Url],   Title AS [Area Title]  from Webs  
    Where fullurl NOT like ‘%sites%’ AND fullUrl <>       ‘MySite’ AND fullUrl <> ‘personal’
  • List of the total portal area:
    select COUNT(*)from Webs   Where fullurl NOT like ‘%sites%’ AND       fullUrl <> ‘MySite’ AND fullUrl <> ‘personal’
  • List of all top level and sub sites in the portal:
    select Webs.FullUrl As [Site Url],   Title AS [WSS Site Title]  from webs 
    where fullurl  like ‘%sites%’ AND fullUrl <>        ‘MySite’ AND fullUrl <> ‘personal’
  • List of the total top level and sub sites in the portal:
    select COUNT(*) from webs  where fullurl  like ‘%sites%’ AND fullUrl <>       ‘MySite’  AND fullUrl <> ‘personal’
  • List of all list/document libraries and total items:
    select    case when webs.fullurl = ”   then ‘Portal Site’   else webs.fullurl  end as [Site Relative Url],  
    webs.Title As [Site Title],   case tp_servertemplate  when 104 then ‘Announcement’  when 105 then ‘Contacts’ 
    When 108 then ‘Discussion Boards’  when 101 then ‘Docuemnt Library’  when 106 then ‘Events’  when 100 then ‘Generic List’ 
    when 1100 then ‘Issue List’  when 103 then ‘Links List’  when 109 then ‘Image Library’  when 115 then ‘InfoPath Form Library’ 
    when 102 then ‘Survey’  when 107 then ‘Task List’  else ‘Other’ end as Type,  tp_title ‘Title’,   tp_description As Description,  
    tp_itemcount As [Total Item]  from lists inner join webs ON lists.tp_webid = webs.Id 
    Where tp_servertemplate IN (104,105,108,101,       106,100,1100,103,109,115,102,107,120)  order by tp_itemcount desc
    Note: the tp_servertemplate field can have the following values:
    • 104  = Announcement
    • 105 = Contacts List
    • 108 = Discussion Boards
    • 101 = Document Library
    • 106 = Events
    • 100 = Generic List
    • 1100 = Issue List
    • 103 = Links List
    • 109 = Image Library
    • 115 = InfoPath Form Library
    • 102 = Survey List
    • 107 = Task List

 

  • List of document libraries and total items:
    select    case when webs.fullurl = ”   then ‘Portal Site’   else webs.fullurl  end as [Site Relative Url],  
    webs.Title As [Site Title],   lists.tp_title As Title,  tp_description As Description,   tp_itemcount As [Total Item] 
    from lists inner join webs ON lists.tp_webid = webs.Id  Where tp_servertemplate = 101  order by tp_itemcount desc
  • List of image libraries and total items:
    select case when webs.fullurl = ”   then ‘Portal Site’   else webs.fullurl  end as [Site Relative Url],  
    webs.Title As [Site Title],   lists.tp_title As Title,  tp_description As Description,   tp_itemcount As [Total Item] 
    from lists inner join webs ON lists.tp_webid = webs.Id  Where tp_servertemplate = 109  — Image Library  order by tp_itemcount desc
  • List of announcement list and total items:
    select case when webs.fullurl = ”   then ‘Portal Site’   else webs.fullurl  end as [Site Relative Url],  
    webs.Title As [Site Title],   lists.tp_title As Title,  tp_description As Description,   tp_itemcount As [Total Item] 
    from lists inner join webs ON lists.tp_webid = webs.Id  Where tp_servertemplate = 104  — Announcement List  order by tp_itemcount desc
  • List of contact list and total items:
    select case when webs.fullurl = ”   then ‘Portal Site’   else webs.fullurl  end as [Site Relative Url], 
    webs.Title As [Site Title],   lists.tp_title As Title,  tp_description As Description,   tp_itemcount As [Total Item] 
    from lists inner join webs ON lists.tp_webid = webs.Id  Where tp_servertemplate = 105   — Contact List  order by tp_itemcount desc
  • List of event list and total items:
    select case when webs.fullurl = ”   then ‘Portal Site’   else webs.fullurl  end as [Site Relative Url],  
    webs.Title As [Site Title],   lists.tp_title As Title,  tp_description As Description,   tp_itemcount As [Total Item] 
    from lists inner join webs ON lists.tp_webid = webs.Id  Where tp_servertemplate = 106   — Event List  order by tp_itemcount desc
  • List of all tasks and total items:
    select    case when webs.fullurl = ”   then ‘Portal Site’   else webs.fullurl  end as [Site Relative Url],  
    webs.Title As [Site Title],   lists.tp_title As Title,  tp_description As Description,   tp_itemcount As [Total Item] 
    from lists inner join webs ON lists.tp_webid = webs.Id  Where tp_servertemplate = 107  — Task List  order by tp_itemcount desc
  • List of all InfoPath form library and total items:
    select    case when webs.fullurl = ”   then ‘Portal Site’   else webs.fullurl  end as [Site Relative Url],  
    webs.Title As [Site Title],   lists.tp_title As Title,  tp_description As Description,   tp_itemcount As [Total Item] 
    from lists inner join webs ON lists.tp_webid = webs.Id  Where tp_servertemplate = 115  — Infopath Library  order by tp_itemcount desc
  • List of generic list and total items:
    select    case when webs.fullurl = ”   then ‘Portal Site’   else webs.fullurl  end as [Site Relative Url],  
    webs.Title As [Site Title],   lists.tp_title As Title,  tp_description As Description,   tp_itemcount As [Total Item] 
    from lists inner join webs ON lists.tp_webid = webs.Id  Where tp_servertemplate = 100  — Generic List  order by tp_itemcount desc

 

 REF: <http://aaalogic.com/sharepoint/sharepoint_1.html>

Filter Content Query Web Part

Add the SharePoint 2010 content query webpart. Edit filter properties:

[PageQueryString : <Query string name >]

[PageFieldValue: <field display name>]

eg:

Load Balancing Incoming Email in SharePoint 2007/2010

 Ref: 

http://blogs.technet.com/b/speschka/archive/2009/05/10/load-balancing-incoming-email-in-sharepoint-2007.aspx

After a recent bout of teaching and testing folks, it became obvious that we are somewhat lacking in our information about some of the finer points of configuring incoming email in SharePoint 2007.  So, below are some notes that I made around some of the SMTP and Exchange configuration steps that are necessary to get things working well.

Items 1 through 3 are applicable exclusively to routing incoming mail, and are all about configuring the IIS SMTP Service that you would typically run on one of your SharePoint web front end servers.  Remember you configure the SMTP Service in Windows Server 2003 by using the IIS Manager snap-in.  It also assumes that you have Exchange 2007 in your organization and a Send Connector already configured for an Address Space that a) includes the name of the server (like wfe1.foo.local) and the network smart host mapping in that connector is configured to send it to the same server.  For example, the Send Connector would have an Address Space of wfe1.foo.local and a smart host configured on the network tab of wfe1.foo.local.

1.  In the Access…Relay Restrictions settings you can restrict relay to ONLY the Exchange server that is going to route messages to the SharePoint farm, and deny all others.  You can do the same for Access…Connection Control.

2.  In Delivery…Advanced, if you DON’T have to use the same delivery name in Masquerade domain that is configured in the SharePoint Incoming Email Settings in Central Admin (like @wfe01.foo.local).  Masquerade domain just allows you to have a different domain name displayed on outgoing messages from the SMTP server (like non delivery messages).

3.  In Delivery…Advanced Smart host, you can leave that field blank and incoming messages are still delivered.

4.  If you are load balancing email between multiple SharePoint servers running the IIS SMTP service, it can beVERY difficult to get working.  Assume for example that you have two WFEs in the farm, and their server names are wfe1.foo.local and wfe2.foo.local.  You want to use both of them for routing incoming mail so you have some high availability for incoming email in the farm.  Also assuming you have Exchange 2007 SP1 in your organization and that’s what your users use for their email server.

To begin with, you need some load balancing mechanism in place in the farm.  You should already have this if you have multiple web front end servers.  For purposes of our conversation we’ll assume you have NLB on your web front ends and they use a Virtual IP (VIP) of 10.10.10.100.

Next, you need an alias for those SMTP servers; that’s the first part of the name that will become part of the document library email address.  Lets assume you want to use “mossmail” as your SMTP servers email alias.  That means that the email addresses for your document libraries will be something likeLibraryName@mossmail.foo.local (since in our example our local domain is called ‘foo.local’).  We now have all of the information we need to configure our servers.

Start with DNS – create a Host (A) record called mossmail in the foo.local zone; give it an address of 10.10.10.100.  Now any requests for mossmail.foo.local will go to the VIP address of 10.10.10.100, and NLB will be responsible for passing the request to either wfe1 or wfe2.  NOTE:  for routing email internally only, you DO NOT need an MX record.

In Exchange, we need a Send Connector.  The Send Connector is where we configure a set of mail addresses that Exchange should look for, and the server(s) it should send those messages to.  In this case we’ll create a new Send Connector and in the Address Space we’ll add a new SMTP address space of mossmail.foo.local.  In the Network settings for the connector, we’ll configure it to route the mail to following smart hosts:  mossmail.foo.local.  So at this point if a user opens up Outlook and sends a message toLibraryName@mossmail.foo.local, that message is sent to Exchange.  Exchange looks at the Send Connector and sees that it should route messages for mossmail.foo.local to a “server” called mossmail.foo.local.  It looks up that address in DNS, gets the VIP of 10.10.10.100 back and sends the SMTP message to that address.  NLB picks up the request and routes it to either wfe1 or wfe2.

The final piece of the configuration happens on the the web front end servers running the SMTP service – in our case, wfe1 and wfe2.  First, you need to make sure the SMTP service is configured to start automatically.  Next, you’ll open up the IIS Manager snap-in, expand it so you can see the Default SMTP Virtual Server, right-click on it and select Properties.  Click on the Access tab and then click on the Relay button.  In the dialog that opens up, enter the IP address of the Exchange server that is going to be routing SMTP messages to the web front end. It is a best practice to limit the ability to relay only to servers that you trust.  So, click the top radio button that says Only the list below, click the Add… button, and type in the IP address of the Exchange Server.  Click OK to close out the Relay dialogs and save those changes.  Note that you can also make the same change using the Connection button.  It will just further insulate you from exposure if you think you need it.  Next, click on the Delivery tab, and then the Advanced… button.  This next step is not strictly required, but it is a good practice in terms of keeping your naming schemes consistent from an SMTP perspective.  In the Fully-qualified domain name edit box, type mossmail.foo.local.  Click the OK button to save those changes, then click the OK button to close out the Properties dialog.  Finally, the last thing needed is a domain alias, so that the SMPT server knows that it is responsible for routing email for the mossmail.foo.local domain.  In the IIS Manager snap-in, expand the Default SMTP Virtual Server tree and click on the Domains object.  Right-click on it and select the New…Domain… menu.  A wizard will start up; click the Alias radio button and then the Next button.  Type mossmail.foo.local in the Name edit field then click the Finish button.  Finally, YOU MUST restart the SMTP service for these changes to take effect.

The rest of the configuration takes place in SharePoint’s Central Admin…Incoming Email Settings now.  While I won’t walk through that step-by-step, I will just say that in the E-mail server display address edit field, type in mossmail.foo.local when you are saving your changes.  Now, create a new or mail enable an existing document library, give it an email address, and send it a message with an attachment.  You should hopefully be good to go at this point.

5.  For outgoing mail, like when you create an alert and you receive the alert confirmation email, it doesn’t use any settings on the local SMTP servers.  Instead it relies entirely upon the SMTP server name that was configured in the Central Admin Outgoing email settings.

So the net is pretty simple:

For incoming emails, you can plug in the name of a single server (like img5.foo.local) or a load balanced name (like mossmail.foo.local).  Each one of those servers (either the single server or all of the servers in the load balanced name mossmail.foo.local) need to have their SMTP server configured and running.  The setup is extensive for a load balanced SMTP server scenario, but very quick and easy for a single server.

 

Pasted from <http://blogs.technet.com/b/speschka/archive/2009/05/10/load-balancing-incoming-email-in-sharepoint-2007.aspx>