Quantcast
Channel: SharePoint 2010 - Development and Programming forum
Viewing all articles
Browse latest Browse all 11571

PowerShell Populate XML Values from CSV

$
0
0

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


Viewing all articles
Browse latest Browse all 11571

Trending Articles



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