PowerShell: get all fields / columns of a content type

this script both prints and write to a file

$site = Get-SPSite http://lamasadmin
$web = $site.RootWeb
$s = ""

foreach ($ctype in $web.ContentTypes)
{
if ($ctype.Id -eq "0x010100C568DB52D9D0A14D9B2FDCC96666E9F2")
{
$ctype.Name + "   " + $ctype.Id
foreach ($field in $ctype.Fields)
{
$field.Title + "   " + $field.Id
$s += '"' + $field.Title + '", ' + $field.Id + [Environment]::NewLine
}
}
}

$s >> "c:\test.csv"

and to write is as html
$s += '<tr><td>' + $field.Title + '</td><td>' + $field.Id + '</td></tr>'

Comments

Popular posts from this blog

OverTheWire[.com] Natas Walkthrough - JUST HINT, NO SPOILERS

SOLVED The item could not be indexed successfully because the item failed in the indexing subsystem

Asp.Net Ending Response options, Response.End() vs CompleteRequest()