Get ContentDatabase info for each site collections
I want to get info about contentDatabase for each site collections in the farm using powershell. When I run this I get an error. Please advise how can get the requested info. PS C:\> [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") PS C:\> $site = New-Object Microsoft.SharePoint.SPSite("https://test") PS C:\> $site.ContentDatabase out-lineoutput : The field/property: "Id" for type: "Microsoft.SharePoint.Administration.SPContentDatabase" differs only in case from the field/property: "ID". Failed to use non CLS compliant type.
June 3rd, 2012 12:45pm

Hi, try following command Get-SPContentDatabase | %{Write-Output "- $($_.Name); foreach($site in $_.sites){write-Output $site.url}} to get more info on this error please check http://www.nivot.org/post/2007/10/24/NonCLSCompliantTypesInPowerShell.aspx http://blogs.catapultsystems.com/tlingenfelder/archive/2009/06/26/using-non-cls-compliant-types-in-powershell.aspx http://sharepointrelated.com/2012/03/09/get-site-collections-per-content-database-one-liner/ hope this helpsWarm Regards, Pratik Vyas | SharePoint Consultant | http://sharepointpratik.blogspot.com/ | Posting is provided "AS IS" with no warranties, and confers no rights
Free Windows Admin Tool Kit Click here and download it now
June 3rd, 2012 3:00pm

i forgot to mention the environment is SharePoint 2007.
June 3rd, 2012 5:02pm

For MOSS 2007, the simplest way is stsadm -o enumsites -url <WEB APP URL> > c:\siteinfo.txt This will create siteinfo.txt in C drive and gives you all site collection information with respective content DB Let us know if this will be helpfulWarm Regards, Pratik Vyas | SharePoint Consultant | http://sharepointpratik.blogspot.com/ | Posting is provided "AS IS" with no warranties, and confers no rights
Free Windows Admin Tool Kit Click here and download it now
June 3rd, 2012 5:17pm

is there way to void using stsadm command.
June 3rd, 2012 5:33pm

In SharePoint 2007, stsadm is the most recommended way to perform this operation. other than stsadm you can try with SQL query to pull information of all site collections associated with specific DB refer http://devdotnotes.wordpress.com/2012/01/27/common-sql-queries-for-sharepoint-content-database/ http://dirkvandenberghe.com/2008/02/18/pulling-site-collections-details-via-direct-sql-query-by-josef-nielsen.htmlWarm Regards, Pratik Vyas | SharePoint Consultant | http://sharepointpratik.blogspot.com/ | Posting is provided "AS IS" with no warranties, and confers no rights
Free Windows Admin Tool Kit Click here and download it now
June 3rd, 2012 5:41pm

Hi. You can use the following C# code for the same: using (SPSite site = new SPSite("siteUrl")) { SPContentDatabase database = site.ContentDatabase; //Your Information Logic } I hope this will help you out.Thanks, Rahul Rashu
June 4th, 2012 2:51am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics