Quantcast
Channel: SharePoint 2010 - Setup, Upgrade, Administration and Operations forum
Viewing all articles
Browse latest Browse all 13778

Powershell create site columns from XML

$
0
0
Hi,
I need to create around 50 custom site columns via powershell.
My XML file has this content
<SiteColumns>
<Field Type="DateTime"
Name="DOcumentationReview"
Description="Shows the next review date of the document"
DisplayName="Development Review Team"
StaticName="DevReviewReview"
Group="SP2010 Applications"
Hidden="FALSE"
Required="FALSE"
Sealed="FALSE"
ShowInDisplayForm="TRUE"
ShowInEditForm="TRUE"
ShowInListSettings="TRUE"
ShowInNewForm="TRUE"></Field>
</SiteColumns>
I decided to read the xml file in the usual way as 
[xml]$s = get-content sitecolumns.xml
Now I want to get the complete node <Field as a string so that I can use in this fashion.
$siteColl = Get-SPSite -Identity "http://mydevsite/"
$rootWeb = $siteColl.RootWeb
$fieldXMLString = '<Field Type="DateTime"
Name="DOcumentationReview"
Description="Shows the next review date of the document"
DisplayName="Development Review Team"
StaticName="DevReviewReview"
Group="SP2010 Applications"
Hidden="FALSE"
Required="FALSE"
Sealed="FALSE"
ShowInDisplayForm="TRUE"
ShowInEditForm="TRUE"
ShowInListSettings="TRUE"
ShowInNewForm="TRUE"></Field>'
$rootWeb.Fields.AddFieldAsXml($fieldXMLString)
How can I loop through the 'Field' node and get the entire node content as a string?

Viewing all articles
Browse latest Browse all 13778

Latest Images

Trending Articles



Latest Images

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