Old question but I thought I'd post a possible solution here for anyone looking.
There is no such flag and using SPBuiltInContentTypeId
is not sufficient because it doesn't include all built in content types.
Based on the SharePoint 2013 content types here I've cobbled this together. I've run this on my own farm and the only content types I got back that weren't user-created were SQL Server Reporting Services ones. The list of content types was small enough for me to manually filter these out.
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
Function global:Get-SPWebApplication($WebAppURL)
{
return [Microsoft.SharePoint.Administration.SPWebApplication]::Lookup($WebAppURL)
}
Function global:Write-File($contenttype, $url)
{
foreach ($ct in $allcts)
{
$isCustomCT = $true
if ($contenttype.Id.ToString() -eq $ct)
{
$isCustomCT = $false
break
}
}
if ($isCustomCT -eq $true)
{
"$($contenttype.Name)`t$($contenttype.ID)`t$($url)`t$($contenttype.Group))" | Out-File $File -append
}
}
$allcts = "0x"`
,"0x00A7470EADF4194E2E9ED1031B61DA0884"`
,"0x00A7470EADF4194E2E9ED1031B61DA088401"`
,"0x00A7470EADF4194E2E9ED1031B61DA088402"`
,"0x00A7470EADF4194E2E9ED1031B61DA088403"`
,"0x00A7470EADF4194E2E9ED1031B61DA088404"`
,"0x01"`
,"0x01000F389E14C9CE4CE486270B9D4713A5D6"`
,"0x010018F21907ED4E401CB4F14422ABC65304"`
,"0x010019ACC57FBA4146AFA4C822E719824BED"`
,"0x010027FC2137D8DE4B00A40E14346D070D52"`
,"0x010027FC2137D8DE4B00A40E14346D070D5201"`
,"0x01002A2479FF33DD4BC3B1533A012B653717"`
,"0x01002CF74A4DAE39480396EEA7A4BA2BE5FB"`
,"0x01003A8AA7A4F53046158C5ABD98036A01D5"`
,"0x01004613D6562E4C41A7B9DADDAC1689E00D"`
,"0x01004C9F4486FBF54864A7B0A33D02AD19B1"`
,"0x01004D5A79BAFA4A4576B79C56FF3D0D662D"`
,"0x01007CE30DD1206047728BAFD1C39A850120"`
,"0x0100807FBAC5EB8A4653B8D24775195B5463"`
,"0x010085EC78BE64F9478AAE3ED069093B9963"`
,"0x010087D89D279834C94E98E5E1B4A913C67E"`
,"0x01009AF87C5C1DF34CA38277FEABCB5018F6"`
,"0x01009BE2AB5291BF4C1A986910BD278E4F18"`
,"0x0100A2CA87FF01B442AD93F37CD7DD0943EB"`
,"0x0100AA27A923036E459D9EF0D18BBD0B9587"`
,"0x0100C30DDA8EDB2E434EA22D793D9EE42058"`
,"0x0100CA13F2F8D61541B180952DFB25E3E8E4"`
,"0x0100DC2417D125A4489CA59DCC70E3F152B2"`
,"0x0100F95DB3A97E8046B58C6A54FB31F2BD46"`
,"0x0100FBEEE6F0C500489B99CDA6BB16C398F7"`
,"0x0101"`
,"0x01010000DEC92EFE5D445789D9FE4A3225A381"`
,"0x01010007FF3E057FA8AB4AA42FCB67B453FFC1"`
,"0x01010007FF3E057FA8AB4AA42FCB67B453FFC100E214EEE741181F4E9F7ACC43278EE811"`
,"0x01010007FF3E057FA8AB4AA42FCB67B453FFC100E214EEE741181F4E9F7ACC43278EE8110003D357F861E29844953D5CAA1D4D8A3B"`
,"0x0101000F1C8B9E0EB4BE489F09807B2C53288F"`
,"0x0101000F1C8B9E0EB4BE489F09807B2C53288F0054AD6EF48B9F7B45A142F8173F171BD1"`
,"0x0101000F1C8B9E0EB4BE489F09807B2C53288F0054AD6EF48B9F7B45A142F8173F171BD10003D357F861E29844953D5CAA1D4D8A3A"`
,"0x0101002039C03B61C64EC4A04F5361F3851066"`
,"0x0101002039C03B61C64EC4A04F5361F385106601"`
,"0x0101002039C03B61C64EC4A04F5361F385106602"`
,"0x0101002039C03B61C64EC4A04F5361F385106603"`
,"0x0101002039C03B61C64EC4A04F5361F385106604"`
,"0x0101002039C03B61C64EC4A04F5361F385106605"`
,"0x0101002039C03B61C64EC4A04F5361F3851068"`
,"0x01010058DDEB47312E4967BFC1576B96E8C3D4"`
,"0x010100629D00608F814DD6AC8A86903AEE72AA"`
,"0x010100734778F2B7DF462491FC91844AE431CF"`
,"0x0101009148F5A04DDD49CBA7127AADA5FB792B"`
,"0x0101009148F5A04DDD49CBA7127AADA5FB792B00291D173ECE694D56B19D111489C4369D"`
,"0x0101009148F5A04DDD49CBA7127AADA5FB792B006973ACD696DC4858A76371B2FB2F439A"`
,"0x0101009148F5A04DDD49CBA7127AADA5FB792B00AADE34325A8B49CDA8BB4DB53328F214"`
,"0x010100A2E3C117A0C5482FAEE3D57C48CB042F"`
,"0x010100B4CBD48E029A4AD8B62CB0E41868F2B0"`
,"0x010100C5033D6CFB8447359FB795C8A73A2B19"`
,"0x010100C568DB52D9D0A14D9B2FDCC96666E9F2"`
,"0x010100C568DB52D9D0A14D9B2FDCC96666E9F2007948130EC3DB064584E219954237AF39"`
,"0x010100C568DB52D9D0A14D9B2FDCC96666E9F2007948130EC3DB064584E219954237AF3900242457EFB8B24247815D688C526CD44D"`
,"0x010100C568DB52D9D0A14D9B2FDCC96666E9F2007948130EC3DB064584E219954237AF39004C1F8B46085B4D22B1CDC3DE08CFFB9C"`
,"0x010100C568DB52D9D0A14D9B2FDCC96666E9F2007948130EC3DB064584E219954237AF39004C1F8B46085B4D22B1CDC3DE08CFFB9C0055EF50AAFF2E4BADA437E4BAE09A30F8"`
,"0x010100C568DB52D9D0A14D9B2FDCC96666E9F2007948130EC3DB064584E219954237AF390064DEA0F50FC8C147B0B6EA0636C4A7D4"`
,"0x010100C568DB52D9D0A14D9B2FDCC96666E9F2007948130EC3DB064584E219954237AF3900796F542FC5E446758C697981E370458C"`
,"0x010100C568DB52D9D0A14D9B2FDCC96666E9F2007948130EC3DB064584E219954237AF3900B46186789C3140CC85BE610336E86BBB"`
,"0x010100C568DB52D9D0A14D9B2FDCC96666E9F2007948130EC3DB064584E219954237AF3900FD0E870BA06948879DBD5F9813CD8799"`
,"0x010100E8711F0F931646FA949751442A907B22"`
,"0x010100F8EF98760CBA4A94994F13BA881038FA"`
,"0x010100FDA260FD09A244B183A666F2AE2475A6"`
,"0x010101"`
,"0x010102"`
,"0x010104"`
,"0x010105"`
,"0x010106"`
,"0x010107"`
,"0x010108"`
,"0x010109"`
,"0x01010901"`
,"0x01010A"`
,"0x01010B"`
,"0x0102"`
,"0x0102004F51EFDEA49C49668EF9C6744C8CF87D"`
,"0x01020072BB2A38F0DB49C3A96CF4FA85529956"`
,"0x0102007DBDC1392EAF4EBBBF99E41D8922B264"`
,"0x0103"`
,"0x0104"`
,"0x0105"`
,"0x0106"`
,"0x0107"`
,"0x0108"`
,"0x0108003365C4474CAE8C42BCE396314E88E51F"`
,"0x010801"`
,"0x01080100C9C9515DE4E24001905074F980F93160"`
,"0x010802"`
,"0x0109"`
,"0x010A"`
,"0x010B"`
,"0x010C"`
,"0x0110"`
,"0x0111"`
,"0x0116"`
,"0x0120"`
,"0x012001"`
,"0x012002"`
,"0x012004"`
,"0x0120D5"`
,"0x0120D520"`
,"0x0120D520A8"`
,"0x0120D520A808"
#Get the SharePoint Farm. Equallent to : Get-SPFarm commandlet
$Farm = [Microsoft.SharePoint.Administration.SPFarm]::Local
#Get All feature of the farm. Equallent to: Get-SPFeature commandlet
$FarmFeatures= $Farm.FeatureDefinitions
$File = Read-Host("Enter the path of the file")
$WebAppURL = Read-Host("Enter your WebApp URL here")
$WebApp = Get-SPWebApplication $WebAppURL
#Scan Web Application Features
#Write the Header to "Tab Separated File"
"CT Name`tCT ID`tURL`tCT Group" | out-file $File
foreach($ctype in $WebApp.ContentTypes)
{
Write-File $ctype $WebAppURL
}
#Get All site collections of the Web Application
$SitesColl = $webApp.Sites
#Iterate through each site collection/sub-site
foreach($Site in $SitesColl)
{
#Iterate through each content type at Site collection level
foreach($ctype in $site.ContentTypes)
{
Write-File $ctype $site.Url
}
foreach($web in $site.AllWebs)
{
#Iterate through each content type at web level
foreach($ctype in $web.ContentTypes)
{
Write-File $ctype $Web.Url
}
}
}