Retrieve the list of Content Types in MOSS 2007 using PowerShell
MOSS 2007
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") | out-null
Write-host ".."
Write-host ".."
Write-host "Get a list of Content types"
$site = new-object Microsoft.SharePoint.SPSite("https://spweb/extend"); # specify url here
foreach ($web in $site.AllWebs) {
$ctypes = $web.ContentTypes
foreach ($ctype in $ctypes) {
$usages = [Microsoft.Sharepoint.SPContentTypeUsage]::GetUsages($ctype)
foreach ($usage in $usages) {
Write-Host $web.Name + "," + $ctype.Name + "," + $usage.Url
}
}
}
SharePoint 2010
$site = Get-SPSite("https://SPWeb/Site"); # Specify url here
foreach ($web in $site.AllWebs) {
$ctypes = $web.ContentTypes
foreach ($ctype in $ctypes) {
$usages = [Microsoft.Sharepoint.SPContentTypeUsage]::GetUsages($ctype)
foreach ($usage in $usages) {
Write-Host $web.Name + "," + $ctype.Name + "," + $usage.Url
}
}
}