Quantcast
Channel: TechNet Blogs
Viewing all articles
Browse latest Browse all 17778

Retrieve the list of Content Types in MOSS 2007 using PowerShell

$
0
0

 

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("http://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("http://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
}
}
}


Viewing all articles
Browse latest Browse all 17778

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>