Export Fields

Script

Name

Description

Last Modified Date

Download

ExportFields

Exports site fields based on a group

29/01/2012

None

#	Exports fields to a csv
param 
(
	$SiteCollectionUrl = "http://localhost",
	$GroupName =  "Custom Fields",
 	$outFileName = "FieldExport.csv"
)
cls
$site = Get-SPSite $SiteCollectionUrl -ErrorAction:Stop
echo "Processing..."
$fields = $site.RootWeb.Fields | where { $_.Group -like $GroupName }
if($fields.Count -eq 0)
{
	Write-Host "Cannot find any fields for $GroupName"
	return
}
#Header
"InternalName,Title,Id,MaxLength,Description,Group,TypeShortDescription" | Out-File $outFileName
ForEach ($id in $fields)
{
 	'"' + $id.InternalName + `
 	'","' + $id.Title + `
 	'","' + $id.Id + `
 	'","' + $id.MaxLength + `
 	'","' + $id.Description + `
 	'","' + $id.Group + `
 	'","' + $id.TypeShortDescription + `
 	'"' | Out-File $outFileName -append
}
$site.Dispose()
echo "Export complete"

CodeMonkey Software is a division of JCHMedia www.jchmedia.com