Hi all,
I am attempting to create Site Columns in bulk, but am having issues getting the values from my CSV to populate XML. Any advice? (Code snippet to follow):
# Reference the CSV holding the site column values and begin the loop
$create = Import-Csv -path c:\PowerShell\CreateSiteColumns.csv
$create | ForEach-Object {
#Get site and web object
$site = Get-SPSite -Identity $create.SiteCollection
$web = $site.RootWeb
#Assign fieldXML variable with XML string for site column
$fieldXML = '<Field Type="$create.FieldType"
Name="$create.Name"
Description="$create.Description"
DisplayName="$create.DisplayName"
StaticName="$create.StaticName"
Group="$create.Group"
Hidden="$create.Hidden"
Required="$create.Required"
Sealed="$create.Sealed"
ShowInDisplayForm="$create.ShowInDisplayForm"
ShowInEditForm="$create.ShowInEditForm"
ShowInListSettings="$create.ShowInListSettings"
ShowInNewForm="$create.ShowInNewForm"></Field>'
#Output XML to console
write-host $fieldXML}Personal Blog: http://thebitsthatbyte.com